Python脚本完美解决Linux环境解压.zip文件乱码问题

1、vi uzip(文件名)
2、复制以下Python程序

 1 #!/usr/bin/env python
 2 # -*- coding: utf-8 -*-
 3 # uzip.py
 4  
 5 import os
 6 import sys
 7 import zipfile
 8  
 9 print "Processing File " + sys.argv[1]
10  
11 file=zipfile.ZipFile(sys.argv[1],"r");
12 for name in file.namelist():
13     utf8name=name.decode('gbk')
14     print "Extracting " + utf8name
15     pathname = os.path.dirname(utf8name)
16     if not os.path.exists(pathname) and pathname!= "":
17         os.makedirs(pathname)
18     data = file.read(name)
19     if not os.path.exists(utf8name):
20         fo = open(utf8name, "w")
21         fo.write(data)
22         fo.close
23 file.close()

3、chmod +x uzip
4、./uzip xxxx.zip

亲测有效,:)

原文地址:https://www.cnblogs.com/gotodsp/p/5514139.html