-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp6.py
More file actions
39 lines (30 loc) · 824 Bytes
/
p6.py
File metadata and controls
39 lines (30 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
'''
Author:
Kyle Wu <imkylewu@gmail.com>
http://www.kylewu.net
File: p6.py
Create Date: Fri Nov 26 10:39:57 2010
http://www.pythonchallenge.com/pc/def/channel.html
'''
import zipfile
import re
import urllib
import os
if __name__ == "__main__":
source = 'http://www.pythonchallenge.com/pc/def/channel.zip'
save_as = 'temp.zip'
urllib.urlretrieve(source, save_as)
zf = zipfile.ZipFile(save_as, 'r')
f = '90052'
res = []
print zf.read('46145.txt')
while 1:
try:
data = zf.read('%s.txt' % f)
f = "".join( re.findall("is ([0-9]+)", data) )
res.append(zf.getinfo('%s.txt' % f).comment)
print f
except:
print "".join(res)
break
os.remove(save_as)