
def chineseNumber2Int(strNum: str):
result = 0
temp = 1 # 存放一个单位的数字如:十万
count = 0 # 判断是否有chArr
cnArr = ['壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖']
chArr = ['拾', '佰', '仟', '万', '亿']
for i in range(len(strNum)):
b = True
c = strNum[i]
for j in range(len(cnArr)):
if c == cnArr[j]:
if count != 0:
result += temp
count = 0
temp = j + 1
b = False
break
if b:
for j in range(len(chArr)):
if c == chArr[j]:
if j == 0:
temp *= 10
elif j == 1:
temp *= 100
elif j == 2:
temp *= 1000
elif j == 3:
temp *= 10000
elif j == 4:
temp *= 100000000
count += 1
if i == len(strNum) - 1:
result += temp
return result
Mac电脑安装Python软件后怎么查看版本号(附下载地址)
上面是“Python语言如何实现大写汉字和数字的转换”的全面内容,想了解更多关于 后端开发 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_4292.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

推荐一个免费的API接口网站
FoodiesFeed:一个专门提供各种好看的食物、食材、料理高清图片的图片网站
浮图秀插件:一款通过鼠标悬停在缩略图上即可浏览和下载高清图片
Mistral AI:欧洲开源大模型标杆企业,提供了增强的推理、理解和概括