晚上好,
我认为我不能正确理解zipfile结构代码
import xbmc
import zipfile
targetzip = xbmc.translatePath('special://home/userdata/addon_data/plugin.program.tester/test.zip')
extractto = xbmc.translatePath('special://home/userdata/addon_data/plugin.program.tester/')
zip = ZipFile(targetzip)
zip.extractall(extractto)
任何想法为什么它不起作用?
答案 0 :(得分:0)
尝试这样做
import zipfile
fh = open(targetzip, 'rb')
z = zipfile.ZipFile(fh)
for name in z.namelist():
z.extract(name, extractto)
fh.close()
答案 1 :(得分:0)
试试这段代码:
with zipfile.ZipFile(targetzip) as zf:
zf.extractall(extractto)