在这个网站:有python的挑战题目,嘿嘿,从第二题开始做起,
给一段乱码:
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
有个图片:E-》G
我写了转换:
for i in str:
if i>='a' and i<='x':
tmp = tmp + chr(ord(i)+2)
elif i>'x' and i<='z':
tmp = tmp + chr(ord(i)+2-26)
else:
tmp = tmp+i
得到结果:
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
O(∩_∩)O~,难怪说要转换两次,转换URL吧:
transtab= string.maketrans('abcdefghijklmnopqrstuvwxyz','cdefghijklmnopqrstuvwxyzab')
str.translate(transtab,'')
"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"
tmp="map"
tmp.translate(transtab,'')
'ocr'
得到第三题的链接:
下次再做吧。。
阅读(1299) | 评论(0) | 转发(0) |