Python tempfile [Errno 66] Directory not empty

This question already has an answer here:

  • How to delete a file or folder? 9 answers
  • How do I remove/delete a folder that is not empty with Python? 13 answers

  • I'll just note that path = os.path.join(tmpdir) makes path equal to tmpdir . That said, when a directory is not empty, neither os.remove or os.rmdir will work.

    Those are operating system calls, which don't recurse to files contained in the directory.

    So just use

    import shutil
    shutil.rmtree(tmpdir)
    
    链接地址: http://www.djcxy.com/p/42416.html

    上一篇: 如何删除/删除Python中不为空的文件夹?

    下一篇: Python tempfile [Errno 66]目录不为空