Bad magic number error with ZipFile module in Python

前端 未结 2 1079
轻奢々
轻奢々 2020-12-11 16:19

I am using Python 2.7 on Windows 7 (64 bit). When I try to unzip a zip file with ZipFile module I get the following error:-

Traceback (most recent call last)         


        
2条回答
  •  难免孤独
    2020-12-11 16:29

    Make sure you are really opening a ZIP file, not for example a RAR file named with a .zip extension. Proper zip files have a header, which was not found in this case.

    The zipfile module can only open zip files. WinRAR can also open other formats, and it likely ignores the filename and only looks at the file itself.

提交回复
热议问题