0
0

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 3 years have passed since last update.

API

Posted at

import requests
import json
import pprint

import random
url = "https://zipcloud.ibsnet.co.jp/api/search?zipcode=5450042"

result = requests.get(url)
data = json.loads(result.text)
pprint.print(data)
print(type(data))
pprint.pprint(data["results"])

{
"message": null,
"results": [
{
"address1": "大阪府",
"address2": "大阪市阿倍野区",
"address3": "丸山通",
"kana1": "オオサカフ",
"kana2": "オオサカシアベノク",
"kana3": "マルヤマドオリ",
"prefcode": "27",
"zipcode": "5450042"
}

result = requests.get(url)
data = json.loads(result.text)
##pprint.print(data)
print(type(data))
json_data = data["results"][0]

print(f'郵便番号は{json_data["zipcode"]}です。住所は{json_data["address1"]}{json_data["address2"]}{json_data["address3"]}です。')

result :
郵便番号は5450042です。住所は大阪府大阪市阿倍野区丸山通です。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?