我有一个Python程序,它遍历一个目录并生成md5sums。有一个文件被卡住了。运行ls -lA
我发现它具有prw-------
属性。后来我在谷歌上搜索了一下,发现这是一根管子。你知道吗
如何在遍历中检查管道?我只想跳过这个文件。你知道吗
我的遍历代码是:
for dirpath, _, files in walk(folder):
for fname in files:
print join(dirpath, fname)
if not islink(join(dirpath, fname)):
# do something with the file, here I pass it to myClass.
myClass.addFile(dirpath, fname)
您实际上不需要显式地测试管道,只需要查找文件。你知道吗
使用
os.path.isfile()
;它将为管道返回False
,但为实际文件返回True
:相关问题 更多 >
编程相关推荐