# -*- coding: cp936 -*-
'''
Created on 2012-3-24
@author: William
'''
import sys
chiNum=['零','一','二','三','四','五','六','七','八','九']
chiSerie=['零','十','百','千']
num=raw_input("请输入您要转换的介于0~9999的数字:")
try:
num=int(num)
except ValueError:
print "您输入的不是数字,而是字符串,内容为:",num
else:
zeroFlag=0
flag=0
sys.stdout.write( "输入的数字为:")
if num==0:
print chiNum[0]
elif num>9999 or num<0:
print "数字小于0或大于9999,为:",num
else:
for i in range(4):
level=num/pow(10,3-i)
if level==0 and flag==1:
zeroFlag=1
elif level!=0:
flag=1
num=num%pow(10,3-i)
if zeroFlag==1:
sys.stdout.write(chiNum[0])
sys.stdout.write( chiNum[level])
if i!=3:
sys.stdout.write( chiSerie[3-i])
zeroFlag=0