pythonchallenge_level2

简介: pythonchallenge各关解题

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))
相关文章
|
索引
PAT (Advanced Level) Practice - 1056 Mice and Rice(25 分)
PAT (Advanced Level) Practice - 1056 Mice and Rice(25 分)
90 0
PAT (Advanced Level) Practice - 1068 Find More Coins(30 分)
PAT (Advanced Level) Practice - 1068 Find More Coins(30 分)
92 0
PAT (Advanced Level) Practice - 1017 Queueing at Bank(25 分)
PAT (Advanced Level) Practice - 1017 Queueing at Bank(25 分)
109 0
|
Python
pythonchallenge_level5
pythonchallenge各关解题
959 0
|
Python
pythonchallenge_level0
pythonchallenge各关解题
1123 0
|
Python
pythonchallenge_level11
pythonchallenge各关解题
1044 0
|
Python
pythonchallenge_level7
pythonchallenge各关解题
1131 0
pythonchallenge_level13
pythonchallenge各关解题
1089 0

热门文章

最新文章