Python IOError: Errno 13 Permission denied

折月煮酒 提交于 2019-12-01 01:49:54

I venture to guess that test\test is a directory, and some exception occurred. You catch the exception blindly and try to open the directory as a file. That gives Errno 13 on Windows.

Use os.path.isdir to distinguish between files and directories, instead of the try...except.

    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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!