http://www.pythonchallenge.com/pc/def/274877906944.html
everybody thinks twice before solving this.
g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr’q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj.
第二关:观察图片,就是一种凯撒密码,ROT2罢了,就是所有字母往右移动2位。那解密就是了。
line = """
g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj.
"""
rs = ""
for c in line:
if not c.isalpha():
rs += c
else:
rs += chr((ord(c)-97+2) % 26 + 97)
print(rs)
解密后文字是:
i hope you didnt translate it by hand. thats what computers are for. doing it in by hand is inefficient and that’s why this text is so long. using string.maketrans() is recommended. now apply on the url.
提示我用string.maketrans() 方法,好吧没用过,借此学习一下,只是修改下url。
url = 'http://www.pythonchallenge.com/pc/def/map.html'
data = url.split("/")[-1].split(".")[0]
letters = "".join([chr(x) for x in range(ord('a'), ord('z')+1)])
rot_table = str.maketrans(dict(zip(letters, letters[2:]+letters[:2])))
rs = data.translate(rot_table)
print(rs)
好吧,我承认,maketrans 不在string module里了,而是在str 这个built-in的类中。最后结果是ocr 。
下一关URL:http://www.pythonchallenge.com/pc/def/ocr.html
|