python 轉換數字為中文的大寫

2021-07-25 02:49:01 字數 1013 閱讀 8125

python 轉換為中文的大寫數字,比較簡單,有需要的同學可以拿去使用,沒做角和分 可以自己修改

下面為**

#-*-coding:utf-8 -*-

importlogging

importurllib2

# urllib2.request_host('')

num=[1,2,3,4,5,6,7,8,9,0]

cn=['壹','貳','叄','肆','伍','陸','柒','捌','玖','零']

dw=['元','十','百','千','萬']

n='1003'c=len(n)-1

# print c

ln=''c1=0;

foriinn:

nb = int(i) - 1

ifi=='0'andc1==0:

c1=1

passelse:

ifc1==1:

c1=0

ln=ln+ cn[nb]+dw[c]

c=c-1

println

python數字金額轉換為中文大寫金額

python數字金額轉換為中文大寫金額 編寫一函式,將數字金額轉換為中文大寫金額。設最高位考慮到億,最低位考慮到分 如 數字金額為1023.445,轉換為中文大寫金額為 壹仟零佰貳拾叄元肆角伍分 輸入 乙個數字金額 如 1234.5 輸出 中文大寫金額 壹仟貳佰叄拾肆元伍角零分 from decim...

金錢數字中文轉換

上次那個只能實現圓以上的轉換,這次這個可以轉換到角,分 其中使用了泛型類 public string tochinesenumber t num string chinesepos new string string chinese new string string strnum num.tost...

SQL轉換數字中文大寫

1.alter function dbo fn lowertouppermoney num numeric 14,2 returns nvarchar 100 with encryption as begin declare n data nvarchar 20 c data nvarchar 10...