惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
AI
AI
博客园 - 叶小钗
人人都是产品经理
人人都是产品经理
The Cloudflare Blog
Apple Machine Learning Research
Apple Machine Learning Research
Jina AI
Jina AI
大猫的无限游戏
大猫的无限游戏
博客园 - 【当耐特】
V
Visual Studio Blog
博客园 - Franky
宝玉的分享
宝玉的分享
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
I
Intezer
C
Cybersecurity and Infrastructure Security Agency CISA
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
S
SegmentFault 最新的问题
腾讯CDC
T
Threat Research - Cisco Blogs
Last Week in AI
Last Week in AI
酷 壳 – CoolShell
酷 壳 – CoolShell
Webroot Blog
Webroot Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
小众软件
小众软件
C
Cyber Attacks, Cyber Crime and Cyber Security
Hacker News: Ask HN
Hacker News: Ask HN
T
Tor Project blog
WordPress大学
WordPress大学
雷峰网
雷峰网
J
Java Code Geeks
GbyAI
GbyAI
Recorded Future
Recorded Future
F
Full Disclosure
Cisco Talos Blog
Cisco Talos Blog
S
Secure Thoughts
I
InfoQ
量子位
Forbes - Security
Forbes - Security
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
T
Threatpost
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Security Blog
Microsoft Security Blog
Attack and Defense Labs
Attack and Defense Labs
爱范儿
爱范儿
N
News and Events Feed by Topic
V
Vulnerabilities – Threatpost
L
LINUX DO - 最新话题
A
Arctic Wolf
S
Security Affairs

Sonui – 魔帆博客

【记录】使用Golang开发腾讯云函数踩的坑 | 魔帆博客 【笔记】Hydro二次开发总结 前端篇(一) | 魔帆博客 C/C++ 二叉树 | 魔帆博客 Linux 报错Certificate verification failed: The certificate is NOT trusted. | 魔帆博客 Windows10 系统盘开启 Bitlocker | 魔帆博客 【源码】打猎游戏 html 纯原生代码 | 魔帆博客 VS Code C/C++ 环境配置 | 魔帆博客 【技巧】干掉第三方抢票!如何以最快的速度抢到火车票 | 魔帆博客 【记录】Deepin 桌面无限转圈(风火轮) | 魔帆博客 easySQLite使用帮助 | 魔帆博客 【软件】QQ坦白说发送者查看 --已凉 | 魔帆博客 手把手教你重装原版纯净Windows系统-魔帆出品 | 魔帆博客 【软件】XML文本解析器 | 魔帆博客 【软件】Mac OS环境下最强虚拟机软件--Parallels Desktop | 魔帆博客 【镜像】Mac OS X El Capitan 10.11 (15B42) 懒人版安装镜像 支持变色龙和Clvoer引导 | 魔帆博客 【技术向】如何获取指定QQ在线状态 | 魔帆博客 QQ广告屏蔽器 | 魔帆博客 【开源】自己写的机器人插件源码部分开源 | 魔帆博客 5月20号真的是潘金莲毒死武大郎的日子么?? | 魔帆博客
Python 数字大小写转换 | 魔帆博客
Sonui · 2022-03-30 · via Sonui – 魔帆博客


py浮点型运算有一个魔法,例如1.01*3.0=3.0300000000000002
所以全部转为整数运算,最后除100返回

def toInt(value):
    isum = 0
    nums = {'零': 0, '壹': 1, '贰':2, '叁': 3, '肆': 4, '伍': 5, '陆': 6, '柒': 7, '捌': 8, '玖':9}
    dw = {'拾': 3, '元': 2, '佰': 4, '仟': 5, '万' : 6, '角': 1, '分': 0}
    index = 0
    while index < len(value):
        if value[index] != '零':
            if (value[index] == '拾'):
                isum += 1000;
                index += 1
            elif value[index] in nums :
                isum += nums[value[index]] * pow(10, dw[value[index + 1]])
                index += 2
            else:
                index +=1
        else:
            index += 1
    return round(isum, 2) / 100
#输入一个整数,输出其对应的汉字表示数字

n = int(input())
numl = ['零','一','二','三','四','五','六','七','八','九']
dw = ['', '十', '百', '千', '万', '十', '百', '千', '亿']
ret = ""
t = ""
w = 0
hava = False
d = ''
while n > 0:
    d = numl[n % 10]
    if d[0] != '零':
        d += dw[w % 4]
    t = d + t
    if t == '一十':#处理特殊情况
        t = '十'

    if w % 4 == 0:#处理尾零
        while t != "" and t[-1] == '零':
            t = t[0:len(t) - 1]
        t += dw[w]
    wl = False
    ret = t + ret
    t = ""
    n //= 10
    w += 1
#处理连续的零
for i in range(1, len(ret) - 1):
    if i >= len(ret):
        break
    if ret[i] == '零' and ret[i - 1] == '零':
        d = ret[0:i - 1] + ret[i + 1:]
        i -= 1
        ret = d
print(ret)
'''
60005082
六千万五千零八十二

100002
十万零二

67665782
六千七百六十六万五千七百八十二
'''