相关疑难解决方法(0)

我怎样才能避免:"ZipFile实例在提取zip文件时没有属性'__exit__''"?

代码是:

import sys
execfile('test.py')
Run Code Online (Sandbox Code Playgroud)

在test.py我有:

import zipfile
with zipfile.ZipFile('test.jar', 'r') as z:
    z.extractall("C:\testfolder")
Run Code Online (Sandbox Code Playgroud)

此代码生成:

AttributeError ( ZipFile instance has no attribute '__exit__' ) # edited
Run Code Online (Sandbox Code Playgroud)

从python idle运行时,"test.py"中的代码有效.我正在运行python v2.7.10

python zipfile execfile

4
推荐指数
2
解决办法
6363
查看次数

标签 统计

execfile ×1

python ×1

zipfile ×1