Python Challenge

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/u013251692/article/details/78074528

0: It can be seen from a picture request is 2 ** 38, the value can be directly obtained
2 ** 38


1:
Note that when replacing the letter special value y, z need are converted into a, b; and attention only need to replace the letters inside the special value in parentheses and the like without changing; if the case difference, then, calling lower () function to lowercase you can
first use problem-solving cycle

TheStringInQuestion=r'''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.'''

q=''
for x in TheStringInQuestion:
    if x=='y':
        q=q+'a'
        continue
    if x=='z':
        q=q+'b'
        continue
    if 'a'<=x<='x':
        q=q+chr(ord(x)+2)
        continue
    q=q+x
print(q)

get:

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.

Obtain the current url 'map', ocr obtained from this method, the next question is obtained url

Tip Use string.maketrans (), but since Python 3.4 this method has canceled this method, using built-in functions: bytearray.maketrans (), bytes.maketrans (), str.maketrans () instead of this method, and I using Python3.5

 import string

TheStringInQuestion=r''' 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=str.maketrans(string.ascii_lowercase,string.ascii_lowercase[2:]+string.ascii_lowercase[0:2])
answer=TheStringInQuestion.translate(table)
print(answer)

Guess you like

Origin blog.csdn.net/u013251692/article/details/78074528