LoginSignup
3
2

More than 3 years have passed since last update.

[Python]漢字をひらがなに変換してくれる便利なライブラリ

Posted at

pykakasiを使うことで漢字、ひらがな、カタカナの変換を簡単に行うことができます。

コマンドプロンプトで以下のコマンドを入力することでライブラリをインストールすることが可能になります。

pip install pykakasi

使用例

test.py

from pykakasi import kakasi

kakasi = kakasi()
kakasi.setMode('J', 'H') #漢字からひらがなに変換
kakasi.setMode("K", "H") #カタカナからひらがなに変換
conv = kakasi.getConverter()

str = '東京タワー'

print(conv.do(str))

実行結果

python test.py
とうきょうたわー

こんな感じで変換することができるので機会があればぜひ使ってみて下さい。

3
2
0

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
3
2