Archive for the ‘乱码’ tag
Ubuntu 9.10下unzip的乱码问题
Ubuntu 9.10中unzip升级为6.0,结果原来的-O参数没有了,解压缩Win平台来的带中文文件名的文件时,会有乱码。Google,Baidu无果后,自行使用Python解决。
01 #!/usr/bin/python
02 #coding=utf8
03
04 import zipfile
05 import sys
06
07 if len(sys.argv)<2:
08 print u’punzip zipfilename’
09 else:
10 f=zipfile.ZipFile(sys.argv[1])
11 nlist=f.namelist()
12 for n in nlist:
13 m=unicode(n,’gb2312′).encode(‘utf8′)
14 file(m,’wb’).write(f.read(n))
15 f.close()
只有基本功能,解压缩到当前目录下,不能新建目录……
请自行修改。