
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,我们会在看到邮件的第一时间内为您处理!

uniapp如何安装stomp并运用
AI Watch Later插件:一款跨平台视频 “稍后看” 浏览器插件