git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using zipfile to create a zip file with directories and files inside those directories


On 3/7/20 1:08 AM, musbur at posteo.org wrote:
> On Fri, 6 Mar 2020 20:06:40 -0700
> Michael Torrie <torriem at gmail.com> wrote:
> 
>> The documentation talks about writing files from
>> disk, but I'm interested in creating these files from within Python
>> directly in the zip archive.
> 
> But you have seen writestr(), haven't you?

Yes, that's what I was using.  Turns out I didn't look closely enough at
the exception I was getting.  What i thought was zipfile complaining
about a '/' character was really Python complaining about a bad string
formatting string I was using!

Thanks for confirming that zipfile indeed should work the way I hoped it
wood. I'm in business now.

thank you.