Skip to main content

japancode

japancode は、日本の都道府県・市区町村名や各種番号・記号(全国地方公共団体コードなど)を取得・変換するための Python ライブラリです。

現在の対応データ

(現在は都道府県レベルのみ対応しています)

インストール

pip install japancode

使い方

都道府県名のローマ字表記

from japancode import roman

print(roman("東京都"))  # => 'tokyo'
print(roman("東京都", capitalize=True))  # => 'Tokyo'

都道府県名のひらがな・カタカナ表記

from kana import kana

print(kana("東京都"))  # => 'とうきょうと'
print(kana("東京都", katakana=True))  # => 'トウキョウト'

全国地方公共団体コード

from japancode import lgcode

print(lgcode.tocode("東京都"))  # => '130001'
print(lgcode.reverse("130001"))  # => '東京都'

JIS X 0401 (都道府県コード)

from japancode import jiscode

print(jiscode.tocode("東京都"))  # => '13'
print(jiscode.reverse("13"))  # => '東京都'

ISO 3166-2

from japancode import isocode

print(isocode.tocode("東京都"))  # => 'JP-13'
print(isocode.reverse("JP-13")) # => '東京都'

開発・テスト

poetry install
poetry run pytest poetry run pytest ./japancode --doctest-modules --cov -vs

ロードマップ

  • 郵便番号
  • 市区町村レベルのコード
  • 地域メッシュ
  • ローマ字の長音表記対応
  • normalize
  • shorten
  • ドキュメントの整備

クレジット

  • code4fukui/localgovjp : list of local government in Japan (日本の地方自治体一覧オープンデータ) JSON/CSV (CC0)

ライセンス

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

japancode-0.1.0.tar.gz (64.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

japancode-0.1.0-py3-none-any.whl (67.4 kB view details)

Uploaded Python 3

File details

Details for the file japancode-0.1.0.tar.gz.

File metadata

  • Download URL: japancode-0.1.0.tar.gz
  • Upload date:
  • Size: 64.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Darwin/21.6.0

File hashes

Hashes for japancode-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fac5ba31c303a39adf228c44effaa50c98fa9e19a9876dea44de3bebb931c012
MD5 95c195cf2d25de73f4280084996725b5
BLAKE2b-256 410b1c27d7e63f3c3b85bf0ffb5804abf99e89d0f4c14ec88667ca01396cb7ac

See more details on using hashes here.

File details

Details for the file japancode-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: japancode-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 67.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Darwin/21.6.0

File hashes

Hashes for japancode-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 018cbd49becabe01a2c9a7aeca9c3994a58e52655360f9afaa0397b609a3a46b
MD5 fec883bef84538aed3f342d471aed665
BLAKE2b-256 703ec71bd7e838952c4eedc3d61f50d791df5c9270714b3e7578f3ab3f6af20b

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page