其他分享
首页 > 其他分享> > 7-6 sdut-字母替换

7-6 sdut-字母替换

作者:互联网

方法一:使用list

judge = []
for i in range(26):
    judge.append( chr(65+25-i) )
# print(judge)
n= input()
n= [judge[ord(i)-65] if 'A'<=i<='Z' else i for i in n]
print(''.join(n))

方法2:使用map

judge = {}
for i in range(26):
    judge[chr(65+i)]=chr(65+25-i)
# print(judge)
n= input()
n= [judge[i] if 'A'<=i<='Z' else i for i in n]
print(''.join(n))

标签:25,26,字母,print,chr,65,sdut,judge,替换
来源: https://www.cnblogs.com/kingwz/p/16323185.html