编程语言
首页 > 编程语言> > pythonchallenge Level 6

pythonchallenge Level 6

作者:互联网

第6关地址:http://www.pythonchallenge.com/pc/def/channel.html

查看源码获得提示信息zip

url改成zip后得到一个channel.zip文件

解压之后是一堆数字命名的txt,以及一个readme.txt

打开readme.txt获得新的提示

welcome to my zipped list.

hint1: start from 90052

hint2: answer is inside the zip

打开90052.txt 获得提示信息:Next nothing is 94191

也就是需要按顺序打开txt文件

import os

def findTxt(num):
    filename = str(num)+".txt"
    f = open(filename)
    info = f.readline()
    num = info.split(" ")[-1]
    if num.isdigit():
        findTxt(num)
    else:
        print(info)

path = os.getcwd()+"\channel"
os.chdir(path)
findTxt(90052)

运行之后获得新的提示信息:Collect the comments.

也就是要收集comment信息,修改下脚本

import os
import zipfile

orderedFilePath = []
def findTxt(num):
    filename = str(num)+".txt"
    orderedFilePath.append(filename)
    f = open(filename)
    info = f.readline()
    num = info.split(" ")[-1]
    if num.isdigit():
        #print(num)
        findTxt(num)
    else:
        print(info)

path = os.getcwd()+"\channel"
os.chdir(path)
findTxt(90052)
# 获得提示:Collect the comments.

z = zipfile.ZipFile("channel.zip")
for file in orderedFilePath:
    c = z.getinfo(file).comment.decode()
    print(c,end="")
print("")

打印得到hockey

打开:http://www.pythonchallenge.com/pc/def/hockey.html

获得提示:it's in the air. look at the letters.

会发现hockey是由字母组成,oxygen

获得下一关地址:http://www.pythonchallenge.com/pc/def/oxygen.html

标签:info,pythonchallenge,Level,findTxt,filename,num,txt,os
来源: https://www.cnblogs.com/nicole-zhang/p/15557460.html