Created
October 30, 2012 23:51
-
-
Save akira093/3983885 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf-8 | |
# 数字をもらったら漢数字にする | |
import string | |
def toKnaji(n): | |
L1 = [u"",u"一",u"二",u"三",u"四",u"五",u"六",u"七",u"八",u"九"] | |
L1_ = [u"",u"",u"二",u"三",u"四",u"五",u"六",u"七",u"八",u"九"] | |
L2 = [u"",u"十",u"百",u"千"] | |
L3 = [u"",u"万",u"億"] | |
tmp = u"" | |
count1 = 0 | |
count2 = 0 | |
hitoketame = True | |
while n: | |
if count1 == 4: | |
count1 = 0 | |
count2 += 1 | |
hitoketame = True | |
tmp += L3[count2] | |
if n%10: | |
tmp += L2[count1] | |
if hitoketame: | |
tmp += L1[n%10] | |
else: | |
tmp += L1_[n%10] | |
n = n // 10 | |
count1 += 1 | |
hitoketame = False | |
tmp2 = u"" | |
for i in reversed(tmp): | |
tmp2 += i | |
return tmp2 | |
if __name__ == '__main__': | |
#print toKnaji(1234) | |
for i in range(1,1001): | |
print toKnaji(i) + u"反田" + string.uppercase[(i-1)%26] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment