pythonchallenge_level2

level2

地址:http://www.pythonchallenge.com/pc/def/ocr.html
源码:git@code.aliyun.com:qianlizhixing12/PythonChallenge.git。
问题:找出页面源码一点提示注释中的稀有字符。

#!/usr/bin/env python3
# -*- coding:UTF-8 -*-

# Level 2

import urllib.request

url = "http://www.pythonchallenge.com/pc/def/ocr.html"
response = urllib.request.urlopen(url)
body = response.read()
response.close

import re

body = body.decode("utf8")
text = re.search("<!--\n%%(.|\s)+\n-->", body).group(0)
lisall = []
liscop = []

for x in text:
    if not x.isalpha():
        pass
    elif x not in lisall:
        lisall.append(x)
    elif x not in liscop:
        liscop.append(x)
    else:
        pass

lis = [x for x in lisall if x not in liscop]
print("Level 2:", ''.join(lis))
上一篇:pythonchallenge_level7


下一篇:pythonchallenge_level6