Quantcast
Viewing all articles
Browse latest Browse all 7

python challenge level 2

level 2 的链接如下:

从题目的图中看不出什么,但是有这么一句话:

recognize the characters. maybe they are in the book, but MAYBE they are in the page source.

识别字母,可能是在页面源码中

我们来看一下页面源码中有这么一句话:

find rare characters in the mess below

意思是找个下面所有字符中的字母,把这些字符保存到mess.txt,然后用python写个程序找到其中的字符,代码如下:

#!/usr/bin/env python3

def get_charaters(line):
    chars = ""
    for c in line:
        if 'a' <= c <= 'z':
            chars += c
    return chars

try:
    with open("mess.txt") as file:
        for line in file:
            str = get_charaters(line)
            print(str, end = '')
except IOError as err:
    print(err)

运行一下,得到的结果是:

equality

在浏览器中输入http://www.pythonchallenge.com/pc/def/equality.html,果然进入了level 3


Viewing all articles
Browse latest Browse all 7

Trending Articles