PythonChanllenge第六关:Channel

http://www.pythonchallenge.com/pc/def/channel.html

图片的拉链提示暗含了链接channel.zip,下载并解压,发现和前面linkedlist相同的模式。

代码:

import fileinput, re, zipfile

idx = 90052
history = []

while True:
	history.append(idx)
	with fileinput.input(files=(str(idx)+'.txt')) as data:
		data = data.readline()
		print("File" + str(idx) + ":\t" + data)
		idx = "".join(re.findall('[0-9.]', data))
		if len(idx) == 1: 
			break

with zipfile.ZipFile('channel.zip', 'r') as file:
	print(''.join([file.getinfo(str(i)+'.txt').comment.decode("utf-8") for i in history]))


你可能感兴趣的:(File,import)