我看不出我在这里做错了什么
import os
def check():
path = "d://Mu$ic//"
for file in os.listdir(path):
if file.endswith("*.mp3"):
print (os.path.join(path,file))
check()
输出没有显示,知道我做错了什么吗?
最佳答案
省略 *
应该可以,因为 endswith
匹配字符串后缀(与通配符 *.mp3
相反):
file.endswith(".mp3"):
此外,您可以将 //
替换为 /
。
关于python - 检查 mp3 文件是否在给定目录中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45058448/