代码之家  ›  专栏  ›  技术社区  ›  TinyGrasshopper

我不能删除刚刚从python中的zip文件中提取的文件夹

  •  1
  • TinyGrasshopper  · 技术社区  · 15 年前

    wzip=zipfile.zipfile('zipfile.zip')

    关闭()

    os.remove('extractedFolder')

    WindowsError:[错误5]访问被拒绝:“ExtractedFolder”

    我在32位的WindowsVista上使用的是python 2.6,我有点困惑为什么会发生这种情况。

    2 回复  |  直到 15 年前
        1
  •  4
  •   Sanjay Manohar    15 年前

    可能有很多原因。

    1. 你需要使用 os.rmdir
    2. 你需要清空文件夹 首先-记住,windows命令 rmdir /S 移除内容,python可能会使用它。
    3. 同时使用存档的属性?
    4. 没有把它关上。
    5. Windows可能会对包含
        2
  •  1
  •   Gael Varoquaux    15 年前

    file.close() (不过,您的示例代码看起来是正确的)。

    shutils.rmtree