38
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Python用 数字 <-> 漢数字 の相互変換ライブラリ「Kanjize」

Last updated at Posted at 2019-04-20

たとえば


print(int2kanji(55))  # int -> 漢字
    # -> 五十五

print(int2kanji(1250987))  # int -> 漢字
    # -> 百二十五万九百八十七

print(kanji2int("五十五"))  # 漢字 -> int
    # -> 55

print(kanji2int("百二十五万九百八十七"))  # 漢字 -> int
    # -> 1250987

となる関数が欲しいなぁ(kanji2intは見かけましたが、int2kanjiは見当たらなかった)ということで、作りました。

Kanjize

 $ pip install kanjize

from kanjize import int2kanji, kanji2int

で使えます。

10 ** 28 までの整数値は正しく表現できます。

間違っている動作などがあれば、pull requestやissueなどをくださればと思います。

38
12
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
38
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?