在使用os.path.getsize()和os.path.isfile时,我的脚本也返回了.DS_Store文件,这也是我不需要的。我如何忽略这些?如何忽略python函数中的隐藏文件?
import os
root = "/Users/Siddhartha/Desktop/py scripts"
for item in os.listdir(root):
if os.path.isfile(os.path.join(root, item)):
print item
'item.startswith( “”)'? – 2013-03-05 23:02:59
您是否试图忽略只有'.DS_Store',Finder认为“隐藏”的任何内容,Finder认为“隐藏”的任何内容或其在每个平台上的相应内容,......? – abarnert 2013-03-05 23:09:07
或者,也许它是http://stackoverflow.com/questions/284115/cross-platform-hidden-file-detection/6365265#6365265的一个替代,取决于这个问题的答案。 – abarnert 2013-03-05 23:11:41