Python library "Jusho" that converts postal code ⇔ address all over Japan

how to use

$ pip install jusho Install with. Github

from jusho import Jusho

postman = Jusho()

 """Obtained from zip code"""
print(postman.from_postal_code('160-0021')) # '1600021', '〒1600021'Etc. are also valid
  # 〒160-0021,Kabukicho, Shinjuku-ku, Tokyo(TOKYO TO SHINJUKU KU KABUKICHO)

kabukicho = postman.from_postal_code('160-0021')
print(kabukicho.hyphen_postal, kabukicho.prefecture_kanji, kabukicho.city_kanji, kabukicho.town_area_kanji)
  # 160-0021 Kabukicho, Shinjuku-ku, Tokyo
  """In addition to kanji notation, there are also katakana notation and Hepburn notation."""
print(kabukicho.prefecture_kana, kabukicho.prefecture_eng)
  #Tokyo TOKYO TO


  """You can also get the zip code from the address data"""
print(self.postman.address_from_town('Tokyo', 'Shinjuku ward', 'Kabukicho', 'kanji'))
  # 〒160-0021,Kabukicho, Shinjuku-ku, Tokyo(TOKYO TO SHINJUKU KU KABUKICHO)

  """You can also get a list of areas below it from each city or prefecture to help with the notation."""
print(self.postman.prefectures)
  # [('Aichiken', 'Aichi prefecture', 'AICHI KEN'), ('Aomori Ken', 'Aomori Prefecture', 'AOMORI KEN'), ('Akita Ken...
print(self.postman.cities_from_prefecture('Tokyo', 'kanji'))
  # [('Chiyoda', 'Chiyoda Ward', 'CHIYODA KU'), ('Chuo', 'Chuo-ku', 'CHUO KU'), ('Minatok', '...
print(self.postman.towns_from_city('Tokyo', 'Shinjuku ward', 'kanji'))
  # [<Address: 〒160-0000,Shinjuku-ku, Tokyo If not listed below(TOKYO TO SHINJUKU KU IKANIKEISAIGANAIBAAI)>, <Address: 〒160-0005,Aizumi-cho, Shinjuku-ku, Tokyo(TOKYO TO SHINJUKU KU AIZUMICHO)>, <Address: 〒162-0803,Akagishitamachi, Shinjuku-ku, Tokyo(TOKYO TO SHINJUKU KU AKAGI SHITAMACHI)>, <Address: 〒162-0817,Akagi Motomachi, Shinjuku-ku, Tokyo(TOKYO TO SHINJUKU KU AKAGI MOTOMACHI...

Zip code ⇔ address conversion library "Jusho"

Introducing (Stema)

There is still a library called posuto, which also provides almost the same information. However, since it holds json data as a dict internally, it uses a lot of memory and has the disadvantage that it can only search in one direction from zip code to address, and it was a bit uncomfortable for me to use, so a new database I made it a type of library that stores data in.

Thanks to that, it has become possible to search for addresses → zip codes, and I think it has become easier to use.

I used the data officially published by Japan Post, and made up for some missing data by myself.

The usage is as in Usage.

We also have a demo that works as follows. demo

If you have any bugs or requests, please contact github.

Please use it conveniently!

Recommended Posts

Python library "Jusho" that converts postal code ⇔ address all over Japan
[Python] A convenient library that converts kanji to hiragana
[Python] Frequently used library code
That Python code has no classes ...
Code reading of faker, a library that generates test data in Python