URI: [url]http://www.pythonchallenge.com/pc/return/balloons.html[/url]
Username: huge; password: file
说明:
—
解题方法:
过关答案:
../hex/bin
Username: huge; password: file
说明:
—
解题方法:
import gzip, difflib
# Download the GNU zip file from:
# http://www.pythonchallenge.com/pc/return/deltas.gz
h = gzip.open("deltas.gz")
d = difflib.Differ()
part_1, part_2 = [], []
file_1, file_2, file_3 = [], [], []
for line in h:
part_1.append(line[0:53])
part_2.append(line[56:-1])
h.close()
for line in list(d.compare(part_1, part_2)):
if line[0] == "+":
file_1.append(line[2:])
elif line[0] == "-":
file_2.append(line[2:])
else:
file_3.append(line[2:])
for n, data in enumerate((file_1, file_2, file_3)):
temp = []
for line in data:
temp.extend([chr(int(o, 16)) for o in line.strip().split(" ") if o])
h = open("%s.png" % (n + 1), "wb")
h.writelines(temp)
h.close()
# The third file is corrupt and won't be properly displayed by most image
# viewers. It should work in Gecko-based browsers such as Firefox, though过关答案:
../hex/bin
本文通过Python的gzip和difflib模块解析了一个来自pythonchallenge网站的谜题。该挑战涉及下载并处理一个gz压缩文件,对比两个部分的内容差异,并将结果转换为图片。最终生成三张图片,其中一张因损坏可能无法正常显示。
1258

被折叠的 条评论
为什么被折叠?



