我正在用Python将所有文件名列在一个列表中
这是我目前的代码:
import os
from os.path import isfile, join
test = 'C:/Users/Nelly/Desktop/test folder'
one = [f for f in os.listdir(test) if isfile(join(test, f))]
print(one)
上面的代码返回所有文件名的列表。我有一个不希望返回的特定值,即Thumbs.db
。不确定是什么,但不应该在列表中
我如何排除它
Tags:
只需在您的理解中添加一个附加条件:
或者,如果您只想在扩展上进行筛选:
相关问题 更多 >
编程相关推荐