pythonchallenge 第六关

本文完全参考了 http://blog.csdn.net/aegeaner/article/details/7932058

import fileinput, re, zipfile  

idx = 90052  
history = []  
      
while True:  
    history.append(idx)  
    with fileinput.input(files=('E:\TDDOWNLOAD\channel\\'+str(idx)+'.txt')) as data:  
        data = data.readline()  
        print("File" + str(idx) + ":\t" + data)  
        idx = "".join(re.findall('[0-9.]', data))
        print(len(idx))  
        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]))  

 

posted @ 2015-04-28 22:12  istudy2012  阅读(204)  评论(0)    收藏  举报