Answer the question
In order to leave comments, you need to log in
Creating a zip in Python with relative paths?
Good afternoon,
I archive a directory in python with the following code:
def zipdir(path, ziph):
for root, dirs, files in os.walk(path):
for file in files:
ziph.write(os.path.join(root,file))
zipf = zipfile.ZipFile('field/test17.zip', 'w', zipfile.ZIP_LZMA)
zipdir('S:\Folder1\Folder2', zipf)
zipf.close()
Answer the question
In order to leave comments, you need to log in
Put files there not using an absolute path, but using a relative one.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question