level 10
贴吧用户_0RJNyZJ
楼主
原问题:https://www.zhihu.com/question/20523036
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import zipfile
print "Processing File " + sys.argv[1]
if len(sys.argv) > 2:
passwdstr = sys.argv[2];
if not len(sys.argv) > 2:
passwdstr = None;
file=zipfile.ZipFile(sys.argv[1],"r");
for name in file.namelist():
utf8name=name.decode('gbk')
print "Extracting " + utf8name
pathname = os.path.dirname(utf8name)
if not os.path.exists(pathname) and pathname!= "":
os.makedirs(pathname)
file.setpassword(passwdstr)
data = file.read(name)
if not os.path.exists(utf8name):
fo = open(utf8name, "w")
fo.write(data)
fo.close
file.close()
运行这个程序传入两个参数,第一个是文件的路径,第二个是可选参数,为文件解压密码
目前的问题是python自带的zip模块解压效率太低,日后再进行研究
2016年12月27日 08点12分
1
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import zipfile
print "Processing File " + sys.argv[1]
if len(sys.argv) > 2:
passwdstr = sys.argv[2];
if not len(sys.argv) > 2:
passwdstr = None;
file=zipfile.ZipFile(sys.argv[1],"r");
for name in file.namelist():
utf8name=name.decode('gbk')
print "Extracting " + utf8name
pathname = os.path.dirname(utf8name)
if not os.path.exists(pathname) and pathname!= "":
os.makedirs(pathname)
file.setpassword(passwdstr)
data = file.read(name)
if not os.path.exists(utf8name):
fo = open(utf8name, "w")
fo.write(data)
fo.close
file.close()
运行这个程序传入两个参数,第一个是文件的路径,第二个是可选参数,为文件解压密码
目前的问题是python自带的zip模块解压效率太低,日后再进行研究