我编写了一个简单的 for 循环来提取目录中的所有 mps 文件。
for root, dirs, files in os.walk(rootDir, topdown='true'):
# filter the file names
for filename in files:
print(filename); # this prints out filenames as expected
print([file for filename in files if file[-4:] == '.mp3'])
我得到:
TypeError: 'type' object is not subscriptable
有任何想法吗?