n = input()
a = ''
for i in n:
if i in 'abc':
i = 2
elif i in 'def':
i = 3
elif i in 'ghi':
i = 4
elif i in 'jkl':
i = 5
elif i in 'mno':
i = 6
elif i in 'pqrs':
i = 7
elif i in 'tuv':
i = 8
elif i in 'wxyz':
i = 9
elif i.isupper() and i not in 'Z':
i = i.lower()
i = chr(ord(i)+1)
elif i in 'Z':
i = 'a'
i = str(i)
a += i
print(a)
#用 a = ''创建一个空字符串,收集i值
(32229)#在使用ord()和chr()对大写字母进行操作时要注意'Z'比较特殊,因为chr(ord(Z)+1)={ 因此需要将Z单独从大写字母中提出来,并将'a'赋给它。
a = ''
for i in n:
if i in 'abc':
i = 2
elif i in 'def':
i = 3
elif i in 'ghi':
i = 4
elif i in 'jkl':
i = 5
elif i in 'mno':
i = 6
elif i in 'pqrs':
i = 7
elif i in 'tuv':
i = 8
elif i in 'wxyz':
i = 9
elif i.isupper() and i not in 'Z':
i = i.lower()
i = chr(ord(i)+1)
elif i in 'Z':
i = 'a'
i = str(i)
a += i
print(a)
#用 a = ''创建一个空字符串,收集i值
(32229)#在使用ord()和chr()对大写字母进行操作时要注意'Z'比较特殊,因为chr(ord(Z)+1)={ 因此需要将Z单独从大写字母中提出来,并将'a'赋给它。
我已经通过这道题!
https://gw-c.nowcoder.com/api/sparta/jump/link?link=https%3A%2F%2Fwww.nowcoder.com%2FquestionTerminal%2F7960b5038a2142a18e27e4c733855dac
全部评论
相关推荐