```
_MAPPING = (u'零', u'一', u'二', u'三', u'四', u'五', u'六', u'七', u'八', u'九', u'十', u'十一', u'十二', u'十三', u'十四', u'十五', u'十六', u'十七',u'十八', u'十九')
_P0 = (u'', u'十', u'百', u'千',)
_S4 = 10 ** 4
def _to_chinese4(num):
assert (0 <= num and num < _S4)
if num < 20:
return _MAPPING[num]
else:
lst = []
while num >= 10:
lst.append(num % 10)
num = num / 10
lst.append(num)
c = len(lst) # 位数
result = u''
for idx, val in enumerate(lst):
val = int(val)
if val != 0:
result += _P0[idx] + _MAPPING[val]
if idx < c - 1 and lst[idx + 1] == 0:
result += u'零'
return result[::-1]
#b = input("请输入数字:")
list1 = [1,2,4]
b = len(list1)
a = _to_chinese4(b)
print(a)
import datetime
#datetime.datetime.
t = datetime.datetime.now().strftime('%Y年%m月%d日')
print(t)
print(len(list1))
```
```
_MAPPING = (u'零', u'一', u'二', u'三', u'四', u'五', u'六', u'七', u'八', u'九', u'十', u'十一', u'十二', u'十三', u'十四', u'十五', u'十六', u'十七',u'十八', u'十九')
def _to_chinese4(num):
if num < 20:
return _MAPPING[num]
b = input("请输入数字:")
if(int(b)>20):
print('大于20')
else:
w = _to_chinese4(int(b))
print(w)
```
```
_MAPPING = (u'零', u'一', u'二', u'三', u'四', u'五', u'六', u'七', u'八', u'九', u'十', u'十一', u'十二', u'十三', u'十四', u'十五', u'十六', u'十七',u'十八', u'十九')
def _to_chinese4(num):
if num < 20:
return _MAPPING[num]
list1 = [1,2,4]
b = len(list1)
a = _to_chinese4(b)
print(a)
import datetime
t = datetime.datetime.now().strftime('%Y年%m月%d日')
print(t)
print(len(list1))
```
```
a = True
while a:
b = input('请输入小于20数字:')
if int(b)<20:
a = False
else:
print('失败,必须输入小于20的')
```
- py转exe
- py服务器
- py登录
- py查询
- 爬TB热卖1017
- 爬TB分类1015
- 爬BD文库1010
- 爬文库924
- json917
- decode912
- 转码910
- radians829
- turtle827
- 画叶子820
- 树干815
- Turtle, mainloop718
- sorted716
- random711
- turtle.colormode709
- abs704
- begin_fill702
- randint,random627
- isalpha625
- keyword620
- compile618
- judge613
- list1.copy611
- random.choice606
- format_randint604
- save_csv528
- jieba523
- wordcloud521
- wordcloud516
- jieba.lcut514
- counts503
- format423
- 花瓣418
- strftime416
- turtle.fillcolor411
- random.random409
- pensize404
- 花蕊328
- input327
- eval_float320
- open319
- while314
- JCR影响因子313
- _to_chinese4_312
- encoding306
- read305
- flask1029