PythonChallenge Level 1

http://www.pythonchallenge.com/pc/def/map.html 

PythonChallenge Level 1_第1张图片

其实看图片,表达的意思是将字符给转换一下。转换规则为:按字符顺序位移2位。比如,a转换为c,x转换为z,z转换为a……

代码:

import string table = string.maketrans( 'abcdefghijklmnopqrstuvwxyz' , 'cdefghijklmnopqrstuvwxyzab' ) orginal = "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." url = orginal.translate( table ) print url 

结果是:

        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.

所以我们只需:

url = 'map'.translate( table ) print url 

结果:ocr

OK,将map改成ocr,过关!

你可能感兴趣的:(c,table,url,import)