|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
第六题: http://www.pythonchallenge.com/pc/def/channel.html
首先使用以下程序输出文件内容不是Next nothing is ***的文件,得到 46145 Collect the comments.
- # 找到没有数字的提示
- for i in range(910):
- file_path = './channel/' + p + '.txt'
- with open(file_path, 'r') as f:
- content = f.readline()
- if 'Next nothing is ' in content:
- f.seek(16)
- p = f.read()
- else:
- print(p, content)
- break
复制代码
意思是信息在压缩文件的各文件的注释中,按从90052开始一直到46145的顺序输出注释
- import zipfile
- p = '90052'
- file = zipfile.ZipFile('channel.zip', 'r')
- for name in file.namelist():
- content = str(file.read("%s.txt" % p))
- if 'Next nothing is ' in content:
- p = content[18:-1] # 前面是固定字符,因此长度固定,最后一个字符 ' 不取,因此是[18:-1]
- print(file.getinfo("%s.txt" % p).comment.decode("utf-8"), end=" ")
- else:
- break
复制代码
获得提示hockey,输入到url中,得到提示:it's in the air. look at the letters.
完全看不懂,百度说是空气中有氧气,所以密码就是:oxygen |
|