I ' mtryingtoextractzippedfolderusingcodefoundhere。
efunzip(source_filename,dest_dir ) :
with zipfile.zipfile (source _ filename ) as zf:
for member in zf.infolist () :
Words=member.filename.split('/' ) )。
for word in words[:-1]:
drive,word=OS.path.splitdrive,word
head,word=OS.path.split(word ) )。
ifwordin(OS.curdir,os.pardir,'') : continue
ZF.extract(member,path ) ) )。
But when trying to extract,for example,WordPress.zipwithdirectorystructure
wordpress/
-wp-content/
---somefile.php
-wp-config.php
-index.php
ionlygetthefilesinfolderbelowrootfolderorwordpress/in this case.soigetwordpress/WP-content/some file.phpbutnottthefiles
解决方案
thefirstplacetolookisthedocumentation :
zipfile.extractall([path[,members[,pwd]]] )
Applying that to your situation,I'd try:
efunzip(source_filename,dest_dir ) :
with zipfile.zipfile (source _ filename ) as zf:
ZF.extractall(dest_dir ) )。