题解 | #人民币转换#
import sys #from numpy import integer number = input().split(".") L1=["壹","贰","叁","肆","伍","陆","柒","捌","玖" ] L3=["","元","拾","佰","仟","万","拾","百","千万","亿"] L2=["","角","分"] L4 =[ ] L5=[] for i in range(1,10): L4.append(i) dict1={} for i in zip(L1,L4): dict1[i[1]]=i[0] dict1[0]="" integers=list(number[0]) decimals= list(number[1]) if decimals[1]=="0": del decimals[1] for i in range(len(integers)): if dict1[int(integers[::-1][i])]!="": res=dict1[int(integers[::-1][i])]+L3[i+1] L5.append(res) else: pass res="人民币" for x in L5[::-1]: res+=x res=res.replace("壹拾伍万","拾伍万") res=res.replace("壹拾叁元","拾叁元") for i in range(len(decimals)): if dict1[int(decimals[i])]!="": res+=dict1[int(decimals[i])]+L2[i+1] print(res)