How can I avoid: “ZipFile instance has no attribute '__exit__''” when extracting a zip file?
- 阅读更多 关于 How can I avoid: “ZipFile instance has no attribute '__exit__''” when extracting a zip file?
问题 The code is: import sys execfile('test.py') In test.py I have: import zipfile with zipfile.ZipFile('test.jar', 'r') as z: z.extractall("C:\testfolder") This code produces: AttributeError ( ZipFile instance has no attribute '__exit__' ) # edited The code from "test.py" works when run from python idle. I am running python v2.7.10 回答1: I made my code on python 2.7 but when I put it on my server which use 2.6 I have this error : AttributeError: ZipFile instance has no attribute '__exit__' For