题解 | #简单密码#
简单密码
http://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac
while 1: try: passwd = input().strip() passwd = list(passwd) for i in range(len(passwd)): asci = ord(passwd[i]) if asci>=ord('a') and asci<=ord('z'):#当前字符为小写字母 if asci>=ord('a') and asci<=ord('c'): passwd[i] = 2 elif asci>=ord('d') and asci<=ord('f'): passwd[i] = 3 elif asci>=ord('g') and asci<=ord('i'): passwd[i] = 4 elif asci>=ord('j') and asci<=ord('l'): passwd[i] = 5 elif asci>=ord('m') and asci<=ord('o'): passwd[i] = 6 elif asci>=ord('p') and asci<=ord('s'): passwd[i] = 7 elif asci>=ord('t') and asci<=ord('v'): passwd[i] = 8 elif asci>=ord('w') and asci<=ord('z'): passwd[i] = 9 elif asci>=ord('A') and asci<=ord('Z'):#当前字符为小写字母 if passwd[i].lower() == 'z': passwd[i] = 'a' else: passwd[i] = chr(ord(passwd[i].lower())+1) istr = '' for i in passwd: istr+=str(i) print(istr) except EOFError: break