字符串加解密
字符串加解密
http://www.nowcoder.com/questionTerminal/2aa32b378a024755a3f251e75cbf233a
查表咯
code1 = list("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") code2 = list("BCDEFGHIJKLMNOPQRSTUVWXYZAbcdefghijklmnopqrstuvwxyza") code3 = list("0123456789") code4 = list("1234567890") def encrypt(strings): output = "" for i in strings: if 'A' <= i <= 'z': output += code2[code1.index(i)] elif '0' <= i <= '9': output += code4[code3.index(i)] else: output += i return output def decrypt(strings): output = "" for i in strings: if 'A' <= i <= 'z': output += code1[code2.index(i)] elif '0' <= i <= '9': output += code3[code4.index(i)] else: output += i return output while True: try: string1 = input() string2 = input() print(encrypt(string1)) print(decrypt(string2)) except: break