pythonchallenge_level2
level2
地址:https://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 = "https://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))
最後更新:2017-10-01 07:33:16