编写程序,根据用户输入的数字转换成相应的中文的大写数字。例如,1.23转换为“壹点贰参”
def num_to_chinese(num_str):
chinese_numbers = ['零','壹','贰','叁','肆','伍','陆','柒','捌','玖','点']
chinese = "" #创建空字符串
for digit in num_str:
if digit == '0':
chinese = chinese + chinese_numbers[0]
elif digit == '.':
chinese = chinese + chinese_numbers[10]
else:
chinese = chinese + chinese_numbers[int(digit)]
return chinese
# 用户输入
num_str = input("请输入一个数字:")
print(num_to_chinese(num_str))