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

Metadata

Release files for japancode 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for japancode 0.1.0
File Size Uploaded
japancode-0.1.0.tar.gz 64.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for japancode 0.1.0
File Interpreter ABI Platform
japancode-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 131.4 kB

Release files / japancode-0.1.0.tar.gz

Download URL japancode-0.1.0.tar.gz
Size 64.0 kB
Tags Source
SHA-256 checksum
How to use checksums
fac5ba31c303a39adf228c44effaa50c98fa9e19a9876dea44de3bebb931c012
BLAKE2b-256 checksum
How to use checksums
410b1c27d7e63f3c3b85bf0ffb5804abf99e89d0f4c14ec88667ca01396cb7ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.4 Darwin/21.6.0

Release files / japancode-0.1.0-py3-none-any.whl

Download URL japancode-0.1.0-py3-none-any.whl
Size 67.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
018cbd49becabe01a2c9a7aeca9c3994a58e52655360f9afaa0397b609a3a46b
BLAKE2b-256 checksum
How to use checksums
703ec71bd7e838952c4eedc3d61f50d791df5c9270714b3e7578f3ab3f6af20b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.4 Darwin/21.6.0

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page