i want python extract folder , extract random named folder. "random" part figured out no problems. not extract in folder, don't know why. here's code:
... try: print "trying save file " + str(clientaddr) rndstr=randomword(20) file1 = open("comp" + rndstr +".zip","w") file1.write(base64.b64decode(prevdata)) file1.close() zfile = zipfile.zipfile("comp" + rndstr +".zip") zfile.extractall("temp" + rndstr) file2 = open("temp" + rndstr + "/ac","r") #here gives error file doesn't exist. in zip file extract, absolutely sure file named "ac" exists... entire folder remains empty... ... when don't specity output folder, extracts... have absolutely no clue. tried everything...
edit: occur following error:
[errno 2] no such file or directory: 'tempxarkbkfwkxxsiolxglok/ac'
before python 2.7.4 - files might extracted outside path specified.
see note in doc zipfile.extractall
https://docs.python.org/2/library/zipfile.html#zipfile.zipfile.extract
it possible files created outside of path, e.g. members have absolute filenames starting "/" or filenames 2 dots ".."
changed in version 2.7.4: zipfile module attempts prevent that. see extract() note.
Comments
Post a Comment