本题看着很简单,就是在弄出来的老是乱码,看了pcat的wp还是不行,下面的评论说可能是python版本问题,改版本太麻烦,试了一下先gzip解压,得到的文件在打开就不是乱码了,代码如下:
# -*- coding:utf-8 -*-
__author__ = 'gaojie'
import gzip
def foo():
res = open(r'C:UsersgaojieDesktop emp
es.txt', 'w+')
for i in range(1, 243):
path = r'C:UsersgaojieDesktop emp\_sos.extractedext-root\%d' % i
file = gzip.GzipFile(mode='rb', fileobj=open(path, 'rb')).read()
res.write(file)
res.close()
print foo()
python-gzip模块使用:http://www.iplaypy.com/module/gzip.html