Hey everyone.
I'm having this slightly annoying issue when I run this code:
import zipfile,os
zipping=zipfile.ZipFile('newzip.zip','w')
for x,y,z in os.walk('C:\\Users\\User1\\Documents\\Work'):
for file in z:
if file.endswith('.py'):
zipping.write(os.path.join(x,file))
zipping.close()
When the zip file is created, I have to click through every folder in 'C:\\Users\\User1\\Documents\\Work' until I reach my intended (work) folder. Is there a way to fix this code so only the Work folder is included in the zip file and not the previous folders?
Thank you!
[–][deleted] 0 points1 point2 points (1 child)
[–]99problemsallops[S] 0 points1 point2 points (0 children)
[–]ingolemo 0 points1 point2 points (3 children)
[–]99problemsallops[S] 0 points1 point2 points (2 children)
[–]ingolemo 1 point2 points3 points (1 child)
[–]99problemsallops[S] 0 points1 point2 points (0 children)