Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to convert numbers into Chinese characters by python

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the relevant knowledge of "how python converts numbers into Chinese characters". The editor shows you the operation process through actual cases. The operation method is simple, fast and practical. I hope this article "how to convert numbers into Chinese characters in python" can help you solve the problem.

The operating environment of this tutorial: windows7 system, Python 3.9.1 Dell G3 computer.

1. Change the way of thinking

(1) separate integers from decimals.

(2) change four digits into uppercase Chinese characters.

(3) convert two small numbers into x angles and x minutes.

(4) repeat, transfer to RMB capitalization.

2. Examples

Class cnumber: cdict = {} gdict = {} xdict = {} def _ init__ (self): self.cdict = {1: Upright, 2: U 'pick', 3: U 'hundred', 4: U 'thousand'} self.xdict = {1: U 'Yuan', 2: U'wan', 3: U 'billion', 4: U 'trillion'} # numeric identifier self.gdict = {0: U 'Zero' 1: U 'one', 2: U'II', 3: U'3', 4: U 'Restaurant', 5: U'Wu', 6: U'Lu', 7: U'Qi', 8: U 'Qing', 9: U'9'} def csplit (self, cdata): # split function Split the integer string into list g = len (cdata)% 4 csdata = [] lx = len (cdata)-1 if g > 0: csdata.append (Cdata [0: G]) k = g while k

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report