问题描述
我正在尝试查找文件夹中所有以'msCam'开头并以'.avi'扩展名结尾的文件。我设法用以下代码做到这一点:
path = path_to_analyze
files = [i for i in os.listdir(path) if os.path.isfile(os.path.join(path,i)) and \
'msCam' in i]
print(len(files))
for file in files:
if file.endswith(".avi"):
msFileList = [os.path.join(path,file)]
print(msFileList)
但这仅存储在给定的“ msFileList”变量中找到的最后一个文件。
print(msFileList)
如何传递所有要存储的文件?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)