python 打印数字

#encoding=utf-8

import sys

map = {1:"一",2:"二",3: "三",4: "四",5:"五",6:"六",7:"七",8:"八",9:"九",10:"十",100:"百",1000:"千",10000:"万"}

#number = 12345
number = int(sys.argv[1])

read =""
if number > 10000:
    read += map.get(number/10000) + "万"

if number%10000 > 1000:
    read += map.get(number%10000/1000) + "千"

if number/10000 and not(number/1000)%10:
    read += "零" 

if number%10000%1000 > 100:
    read += map.get(number %10000%1000/100) + "百"

if number/1000 and not (number/100)%10:
    read = read.strip("零") + "零"

if number%10000%1000%100 > 10:
    read += map.get(number %10000%1000%100/10) + "十"
if number/100 and not (number/10)%10:
    read = read.strip("零") + "零"


read += map.get(number%10000%1000%100%10)

read = read.strip()

print(read)

输入图片说明

转载于:https://my.oschina.net/innovation/blog/806712

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值