显示错误“只能将str(而不是“list”)连接到str”

2024-04-28 03:57:22 发布

您现在位置:Python中文网/ 问答频道 /正文

这是我的代码,我想导入所有的wav文件存储在我的桌面上。但是每次我改变反斜杠的时候都会显示出一些错误。显示EOL错误。你知道吗

no_of_recordings=[]
for label in labels:
    waves = [f for f in os.listdir('Desktop/yes' + '/'+ labels) if f.endswith('.wav')]
    no_of_recordings.append(len(waves))

错误消息:

TypeError: can only concatenate str (not "list") to str

Tags: 文件ofno代码inforlabels错误