python-gzip解压缩(实验吧SOS)

本题看着很简单,就是在弄出来的老是乱码,看了pcat的wp还是不行,下面的评论说可能是python版本问题,改版本太麻烦,试了一下先gzip解压,得到的文件在打开就不是乱码了,代码如下:

# -*- coding:utf-8 -*-
__author__ = 'gaojie'
import gzip
def foo():
    res = open(r'C:\Users\gaojie\Desktop\temp\res.txt', 'w+')
    for i in range(1, 243):
        path = r'C:\Users\gaojie\Desktop\temp\_sos.extracted\ext-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

posted on 2018-02-02 18:54  gwind  阅读(421)  评论(0编辑  收藏  举报

导航