在元码中我们可以发现注释zip,所以我们猜测本题与python中的zip有关系
python中的zip文件处理相关的知识为:
zipfile是一个python来处理zip压缩包的工具,可以打开追加,查找等相关操作
我们将url后缀修改为.zip之后,下载到一个zip文件….,当然,我门可以解压之后所有的都看了,当然我们第一个应该看的是readme
hint1: start from 90052
hint2: answer is inside the zip
然后我们先找90052,发现里边的内容还是
Next nothing is 94191
好吧,那我们和上一题一样,通过一个循环搞定,反正就是
找一个文件,打开这个文件,获取到下一个需要查找的文件的名称,然后重复这一过程,最后找到没有提示信息的nothing
其实我们要做的就是re.search(“Next nothing is (\d+)”,file.read(“90052.txt”)).group(1)
因为这个90052是个变量,所以
re.search(“Next nothing is (\d+)”,file.read(“%s.txt” % 90052)).group(1)
再然后:
f = “%s.txt”
n = 90052
re.search(nnr, file.read(f % n)).group(1)
n的值会在循环中不断变化….
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import urllib, zipfile, re, collections o, n, f = [], "90052", "%s.txt" nnr = "Next nothing is (\d+)" # Download the ZIP file from http://www.pythonchallenge.com/pc/def/channel.zip file = zipfile.ZipFile("channel.zip") while True: try: n = re.search(nnr, file.read(f % n)).group(1) except: print file.read(f % n) break o.append(file.getinfo(f % n).comment) print "".join(o) |
Latest posts by Zhiming Zhang (see all)
- aws eks node 自动化扩展工具 Karpenter - 8月 10, 2022
- ReplicationController and ReplicaSet in Kubernetes - 12月 20, 2021
- public key fingerprint - 5月 27, 2021