[Tutor] zipfile error message

Wayne Werner waynejwerner at gmail.com
Tue Feb 8 17:16:20 CET 2011


On Mon, 7 Feb 2011, Eric Stevens wrote:

> Hi:
> I am relatively new to Python and have been recently trying to experiment
> with its zipfile capabilities. However, everytime I try to open a zip (
> using method zipfile.ZipFile(open('zipfile.zip','r')) ) I continue to get an
> error message that states:error: unpack requires a string argument of length
> 46. Would anyone be able to help me figure out what is wrong? I am currently
> running Python 2.7 on Windows (not sure if that matters). Thank you.

zip files are not ascii text, so in order to send it to the zipfile you 
need to open it with the 'rb' flag to indicate you want to read in binary 
mode.

HTH,
Wayne


More information about the Tutor mailing list