Python:获得用户输入的一个数字(0~9),替换输入的数字为中文字符
本帖最后由 划句顾 于 2021-6-20 14:30 编辑获得用户输入的一个数字(0~9), 替换输入的数字为中文字符“零一二三四五六七八九”,输出替换后的结果
static/image/hrline/5.gif
方法一:
'''
@author:LaoGu
@time:2021/6/20
'''
a = eval(input("Please input your number:"))
t="零一二三四五六七八九"
if(a==0):
print(t)
elif (a == 1):
print(t)
elif (a == 2):
print(t)
elif (a == 3):
print(t)
elif (a == 4):
print(t)
elif (a == 5):
print(t)
elif (a == 6):
print(t)
elif (a == 7):
print(t)
elif (a == 8):
print(t)
elif (a == 9):
print(t)
static/image/hrline/5.gif
方法二:
a = eval(input("Please input your number:"))
t="零一二三四五六七八九"
print(t)
另一种写法:
a = input("Please input your number:")
t="零一二三四五六七八九"
print(t,end='')
static/image/hrline/5.gif
方法三:
a = eval(input("Please input your number:"))
t="零一二三四五六七八九"
a = t
print(a)
页:
[1]