Traceback (most recent call last): File "d:\ljt\py\а��ڤ������\а��ڤ�����ֲ�����.py", line 230, in <module> if os.path.exists(l1+audios[nn]+l2): TypeError: list indices must be integers or slices, not str
时间: 2024-02-11 09:09:47 浏览: 27
这个错误提示显示你的程序中使用了不正确的列表索引方式。具体来说,你使用了字符串类型的`nn`来索引列表`audios`,而列表索引必须是整数或切片类型。
解决方法是确保`nn`是一个整数类型的数字,可以使用`int()`函数将字符串类型的`nn`转换为整数。例如:
```
nn = int(nn)
if os.path.exists(l1+audios[nn]+l2):
pygame.mixer.music.load(l1+audios[nn]+l2)
pygame.mixer.music.play()
else:
print('File not found: ', l1+audios[nn]+l2)
```
另外,还需要确认你的列表`audios`中的元素是否正确,例如逐个打印列表中的元素,检查是否包含非ASCII字符或其他错误。例如:
```
for audio in audios:
print(audio)
```
这样可以帮助你找出列表中不正确的元素。