Python如何实现中文数字与成绩管理的对照表查询?
- 内容介绍
- 文章标签
- 相关推荐
本文共计577个文字,预计阅读时间需要3分钟。
中文数字对照表:
2、实验题目:中文数字对照表输入一个数字,转换成中文数字。
例如:1234567890 + - 负正负负正正正正正正零。简单直接上代码:pythonnumbers=['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖']def num_to_chinese(num): if num==0: return numbers[0] result='' i=0 while num > 0: digit=num % 10 if digit !=0: result=numbers[digit] + ('十' if i==1 else '') + result else: if result and result[0] !='零': result='零' + result num //=10 i +=1 return result测试print(num_to_chinese(1234567890))
中文数字对照表
2、实验题目:中文数字对照表 输入一个数字,转换成中文数字。比如:1234567890 -> 壹贰叁肆伍陆柒捌玖零。
简单直接上代码。
本文共计577个文字,预计阅读时间需要3分钟。
中文数字对照表:
2、实验题目:中文数字对照表输入一个数字,转换成中文数字。
例如:1234567890 + - 负正负负正正正正正正零。简单直接上代码:pythonnumbers=['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖']def num_to_chinese(num): if num==0: return numbers[0] result='' i=0 while num > 0: digit=num % 10 if digit !=0: result=numbers[digit] + ('十' if i==1 else '') + result else: if result and result[0] !='零': result='零' + result num //=10 i +=1 return result测试print(num_to_chinese(1234567890))
中文数字对照表
2、实验题目:中文数字对照表 输入一个数字,转换成中文数字。比如:1234567890 -> 壹贰叁肆伍陆柒捌玖零。
简单直接上代码。

