自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

在Python代碼中把金額大小寫轉(zhuǎn)換方法

開發(fā) 后端
如果你在是以應(yīng)用中你遇到了把金額小寫轉(zhuǎn)換成金額大寫在Python代碼中,你就可以點(diǎn)擊以下的文章,通過相關(guān)代碼的介紹對(duì)其進(jìn)行了解。

以下的文章主要介紹的是在Python代碼中把金額小寫轉(zhuǎn)換成大寫的實(shí)際應(yīng)用代碼的示例,如果你在用Python代碼中把金額小寫轉(zhuǎn)換成大寫的實(shí)際操作中喲不解之處。你就可以點(diǎn)擊以下的文章對(duì)其進(jìn)行了解。

關(guān)鍵字: Decorator 連接Oracle數(shù)據(jù)庫 SQLObject 設(shè)計(jì)模式 TurboGears 測試框架

本文詳細(xì)介紹把金額小寫轉(zhuǎn)換成大寫的Python代碼功能將小于十萬億元的小寫金額轉(zhuǎn)換為大寫

代碼

 

  1. CODE:  
  2. def IIf( b, s1, s2):  
  3. if b:  
  4. return s1  
  5. else:  
  6. return s2  
  7. def num2chn(nin=None):  
  8. cs =  
  9. ('零','壹','貳','叁','肆','伍','陸','柒','捌','玖','◇','分','角','圓','拾','佰','仟',  
  10. '萬','拾','佰','仟','億','拾','佰','仟','萬')  
  11. st = ''st1='' 
  12. s = '%0.2f' % (nin)  
  13. sln =len(s)  
  14. if sln >; 15: return None  
  15. fg = (nin<1)  
  16. for i in range(0, sln-3):  
  17. ns = ord(s[sln-i-4]) - ord('0')  
  18. st=IIf((ns==0)and(fg or (i==8)or(i==4)or(i==0)), '', cs[ns])  
  19. + IIf((ns==0)and((i<>;8)and(i<>;4)and(i<>;0)or fg  
  20. and(i==0)),'', cs[i+13])  
  21. + st  
  22. fg = (ns==0)  
  23. fg = False 
  24. for i in [1,2]:  
  25. ns = ord(s[sln-i]) - ord('0')  
  26. st1 = IIf((ns==0)and((i==1)or(i==2)and(fg or (nin<1))), '', cs[ns])  
  27. + IIf((ns>;0), cs[i+10], IIf((i==2) or fg, '', '整'))  
  28. + st1  
  29. fg = (ns==0)  
  30. st.replace('億萬','萬')  
  31. return IIf( nin==0, '零', st + st1)  
  32. if __name__ == '__main__':  
  33. num = 12340.1  
  34. print num  
  35. print num2chn(num) 

在Python代碼中把金額小寫轉(zhuǎn)換成大寫的代碼詳解

【編輯推薦】

  1. Python中文轉(zhuǎn)換url編碼的實(shí)際操作步驟介紹
  2. Python學(xué)習(xí)入門中的先搭環(huán)境的具體應(yīng)用的方法介紹
  3. Python源碼分析的實(shí)際相關(guān)操作步驟解析
  4. Python安裝的步驟操作其實(shí)是件很容易的事
  5. 對(duì)Python源代碼組織的相關(guān)實(shí)際操作步驟解析

 

責(zé)任編輯:佚名 來源: 互聯(lián)網(wǎng)
相關(guān)推薦

2020-03-11 10:45:36

Linux命令Linux大小寫

2020-10-14 07:46:46

Linux大小寫轉(zhuǎn)換

2020-10-15 17:55:37

Linux命令行大小寫轉(zhuǎn)換

2010-03-04 14:02:51

Python大小寫

2010-05-26 15:24:09

MySQL字符串

2010-10-11 15:47:46

MySQL字符串大小寫

2009-06-21 13:44:21

LinuxTr大小寫轉(zhuǎn)換

2010-11-25 16:09:58

mysql查詢大小寫

2010-10-27 17:16:51

Oracle查詢

2010-05-11 13:25:18

Mysql大小寫

2011-05-07 10:47:29

Oracle大小寫

2021-06-15 09:39:45

Oracle敏感數(shù)據(jù)庫

2021-06-04 10:30:41

MySQL表名大小

2010-11-26 11:40:19

MySQL字符串大小寫

2010-03-19 13:57:30

Python字符串處理

2010-11-23 13:42:18

mysql數(shù)據(jù)庫大小寫

2017-06-12 16:10:05

MySQL表名

2010-06-07 13:00:34

MySQL數(shù)據(jù)庫

2011-08-30 10:10:30

UbuntuLinuxMySQL

2010-07-15 09:47:09

SQL Server數(shù)
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)