1)如何将大写字母A和小写字母“A”替换为数字1?在
encrp_key = input('Enter the number 1' )
msg = input('Enter some lowercase and some uppercase')
if encrp_key == 1:
new_msg = msg.replace('a ','1').replace('e','2')\
.replace('i','3').replace('o','4').replace('u','5')
## if user types 'ABBSAS acbdcd '
# how do i replace 'A' and 'a' with 1 , E and e with 2 and
# I and i with 3 and so on.
使用^{} :
只是另一种方法:
用
maketrans
生成翻译表。相应的元素被映射到一起。在输出:
^{pr2}$或者你可以这样做:
输出:
^{pr2}$输出:
相关问题 更多 >
编程相关推荐