Directory structure inside a ZipFile object
Scott David Daniels
Scott.Daniels at Acm.Org
Thu Dec 9 10:42:57 EST 2004
Bulba! wrote:
> tried to read file, zip it, and put in the target directory....
>
> It works nice, except the zipfile created contains the directory path
> of the source file -- which I do NOT want to recreate.
Look into the two-argument form of the write command:
import zipfile
archive = zipfile.ZipFile('box.zip', 'w', zipfile.ZIP_DEFLATED)
archive.write('source/somewhere/one.txt', 'name.txt')
archive.write('two.txt', 'another.txt')
archive.close()
--Scott David Daniels
Scott.Daniels at Acm.Org
More information about the Python-list
mailing list