Linux下unzip乱码解决方案

来源:互联网 发布:知无涯者百度云资源 编辑:程序博客网 时间:2024/05/16 11:19
#!/usr/bin/env python# -*- coding: utf-8 -*-import osimport sysimport zipfile#print "Processing File " + sys.argv[1]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)    data = file.read(name)    if not os.path.exists(utf8name):        fo = open(utf8name, "w")        fo.write(data)        fo.closefile.close()
0 0