How to convert numbers into Chinese characters by python
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