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

推荐订阅源

cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
L
LINUX DO - 最新话题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Forbes - Security
Forbes - Security
博客园 - 司徒正美
Hugging Face - Blog
Hugging Face - Blog
W
WeLiveSecurity
Jina AI
Jina AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
N
News and Events Feed by Topic
V
V2EX
Stack Overflow Blog
Stack Overflow Blog
Engineering at Meta
Engineering at Meta
PCI Perspectives
PCI Perspectives
Martin Fowler
Martin Fowler
T
The Exploit Database - CXSecurity.com
F
Full Disclosure
WordPress大学
WordPress大学
S
Security Affairs
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
SegmentFault 最新的问题
P
Privacy International News Feed
IT之家
IT之家
M
MIT News - Artificial intelligence
G
GRAHAM CLULEY
Hacker News: Ask HN
Hacker News: Ask HN
D
DataBreaches.Net
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
C
Check Point Blog
美团技术团队
Security Latest
Security Latest
Cyberwarzone
Cyberwarzone
N
News and Events Feed by Topic
MyScale Blog
MyScale Blog
H
Help Net Security
宝玉的分享
宝玉的分享
The Hacker News
The Hacker News
The Last Watchdog
The Last Watchdog
The Cloudflare Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
爱范儿
爱范儿
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
I
Intezer
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
AI
AI
I
InfoQ
N
News | PayPal Newsroom
TaoSecurity Blog
TaoSecurity Blog

魔帆博客

Python包管理的血泪史:从混乱到秩序的漫长征 | 魔帆博客 Mac mini + iPad 随航梦幻联动!零显示器配置指南,iPad 秒变 Mac 主屏幕 | 魔帆博客 日文中的衬线、非衬线混排 | 魔帆博客 使用 GNU/Linux 搭建多出口软路由 | 魔帆博客 网页排版中的字体衬线 | 魔帆博客 配置和使用 Windows Dev Drive 开发驱动器 | 魔帆博客 解锁iOS侧载自由:使用sideStore轻松搞定ipa签名 | 魔帆博客 Git配置:如何优雅的配置多用户并使用 ssh 密钥验证 | 魔帆博客 Windows 注册表编辑或清除多显示器配置 | 魔帆博客 Git 合并本地两个不同的 Repo 仓库 | 魔帆博客 【记录】使用Golang开发腾讯云函数踩的坑 | 魔帆博客 Git 提示 fatal: unsafe repository is owned by someone else 错误 | 魔帆博客 【笔记】Hydro二次开发总结 前端篇(一) | 魔帆博客 C/C++ 二叉树 | 魔帆博客 Linux 报错Certificate verification failed: The certificate is NOT trusted. | 魔帆博客 安装有 RootMagiskXposedPlay 的 WSA 安卓子系统 | 魔帆博客 Fedora 系统升级 32->34 跨版本升级 | 魔帆博客 教程:如何更新安装 docker-compose V2 和使用 docker switch | 魔帆博客 Windows10 系统盘开启 Bitlocker | 魔帆博客
Python 数字大小写转换 | 魔帆博客
Sonui · 2022-03-30 · via 魔帆博客


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
六千七百六十六万五千七百八十二
'''