import string str1 = string.ascii_uppercase str2 = string.ascii_lowercase str3 = '1 2 3 4 5 6 7 8 9 0' while True: try: #需要加密的密码 data1 = input() #加密过程 #用列表存储加密数据 data2 = [] for word in data1: if word in str1 and word != 'Z': word1 = word.lower() data2.append(chr(ord(word1)+1)) elif word == 'Z': data2.append('a') elif word in str2 and word != 'z': word1 = word.upper() data2.append(chr(ord(word1)+1)) elif word == 'z': data2.append('A') elif word in str3 and word != '9': data2.append(str(int(word)+1)) elif word == '9': data2.append('0') else: data2.append(word) #需要解密的密码 data3 = input() #用空列表存放需要解密的密码 data4 = [] for word in data3: if word in str1 and word != 'A': word1 = word.lower() data4.append(chr(ord(word1)-1)) elif word == 'A': data4.append('z') elif word in str2 and word != 'a': word1 = word.upper() data4.append(chr(ord(word1)-1)) elif word == 'a': data4.append('Z') elif word in str3 and word != '0': data4.append(str(int(word)-1)) elif word == '0': data4.append('9') else: data2.append(word) for k in data2: print(k,end='') print('\r') for k in data4: print(k,end='') print('\r') except: break