zipfile默认对于文件名编码只识别cp437和utf-8 对于采用其他编码方式的文件,zipfile解压出来的就会是乱码 我们可以先把它encode成cp437然后再decode成GBK 最后在把文件重命名回去即可. import zipfile from os import rename # 解压 with zipfile.ZipFile('test.zip', 'r') as fd: for i in fd.namelist(): gbkfilename = i.encode('cp43
在python中编程导入压缩包,利用zipfile包,从zipinfo读取文件名总是出错,创建的文件名是乱码,写入pgsql更是出错. 但在ubuntu下测试却正常,在windows下测试总是失败. if not hdfs.exists_file_dir(dir): hdfs.make_dir(dir) hdfs.create_file(hpath, zip.read(info)) # There is no official file name encoding for ZIP files.
JAVA中对jar文件或zip文件解压的时候,能够使用JDK内置的API:JarFile和ZipFile,在windows下解压这2种格式文件的时候,常常报下面错误: Exception in thread "main" java.lang.IllegalArgumentException: MALFORMED at java.util.zip.ZipCoder.toString(ZipCoder.java:58) at java.util.zip.ZipFile.getZipEntr