题解 | #简单密码#
简单密码
http://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac
import string
u = string.ascii_uppercase
l = string.ascii_lowercase
t = str.maketrans(u,l[1:]+l[0])
d = {"abc":2,"def":3,"ghi":4,"jkl":5,"mno":6,"pqrs":7,"tuv":8,"wxyz":9}
ll=[]
while True:
try:
s = input()
for i in s:
if i in u:
j = i.translate(t)
ll.append(j)
elif i in l:
for k in d.keys():
if i in k:
j = str(d[k])
ll.append(j)
else:
ll.append(i)
print(''.join(ll))
except:
break