我敢猜测这
testtest是一个目录,并且发生了一些异常。您盲目地捕获了异常,然后尝试将目录作为文件打开。这样就可以在Windows上使用Errno
13。
使用
os.path.isdir的文件和目录进行区分,而不是尝试…除了。
for item in os.listdir(pathname): n = os.path.join(pathname, item) if os.path.isdir(n): # List a directory on n scan(n, signatures, depth) else: # Do what you should for a file



