`

Python Challenge (level 1)

阅读更多
URI: http://www.pythonchallenge.com/pc/def/map.html




说明:
图片中显示出字符转换的规律k->m, o->q, e->g
提示用string.maketrans()

解决方法:

import string

original = "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."

table = string.maketrans(
    "abcdefghijklmnopqrstuvwxyz", "cdefghijklmnopqrstuvwxyzab"
)

print original.translate(table)


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.

print "map".translate(trans)

ocr

过关答案:
ocr
  • 大小: 33 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics