-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path6_channel.py
More file actions
35 lines (30 loc) · 926 Bytes
/
6_channel.py
File metadata and controls
35 lines (30 loc) · 926 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
#http://www.pythonchallenge.com/pc/def/channel.html
import os, re, zipfile
# FileBase='5_channel/'
# FileName='90052'
# FileHandle=file(FileBase+FileName+'.txt')
# FileContent=FileHandle.read()
# FileHandle.close()
# temp=re.findall(r'[0-9]+$', FileContent)
# while temp:
# FileName=temp[0]
# FileHandle=file(FileBase+FileName+'.txt')
# FileContent=FileHandle.read()
# print FileContent
# FileHandle.close()
# temp=re.findall(r'[0-9]+$', FileContent)
Comments=[]
ZipFileObj=zipfile.ZipFile('6_channel.zip', 'r')
Prefix='90052'
Surfix='.txt'
while True:
FileContent=ZipFileObj.read(Prefix+Surfix)
Temp=re.findall(r'[0-9]+$', FileContent)
if Temp:
Prefix=Temp[0]
Comments.append(ZipFileObj.getinfo(Prefix+Surfix).comment)
else:
break
print ''.join(Comments)
#http://www.pythonchallenge.com/pc/def/hockey.html
#http://www.pythonchallenge.com/pc/def/oxygen.html