郵便番号をコマンドプロンプトから入力

#!/usr/bin/env python3

# ライブラリの取り込み --- (*1)
import sys
import urllib.request as req
import urllib.parse as parse

if len(sys.argv) <= 1:
	print("USAGE: app.py (keyword)")
	sys.exit()
post = sys.argv[1]

API = "https://maps.googleapis.com/maps/api/geocode/json"
query = {
	"address": post,
    "language": "ja",
    "sensor": "false"
}
params = parse.urlencode(query)
url = API + "?" + params
print("url=", url)

with req.urlopen(url) as r:
	b = r.read()
	data = b.decode("utf-8")
	print(data)

ほう!

[vagrant@localhost python]$ python3 app.py 150-6010
url= https://maps.googleapis.com/maps/api/geocode/json?address=150-6010&sensor=false&language=ja
{
"results" : [
{
"address_components" : [
{
"long_name" : "150-6010",
"short_name" : "150-6010",
"types" : [ "postal_code" ]
},
{
"long_name" : "恵比寿",
"short_name" : "恵比寿",
"types" : [ "political", "sublocality", "sublocality_level_2" ]
},
{
"long_name" : "渋谷区",
"short_name" : "渋谷区",
"types" : [ "locality", "political" ]
},
{
"long_name" : "東京都",
"short_name" : "東京都",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "日本",
"short_name" : "JP",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "日本 〒150-6010",
"geometry" : {
"location" : {
"lat" : 35.6423633,
"lng" : 139.7134531
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 35.6437122802915,
"lng" : 139.7148020802915
},
"southwest" : {
"lat" : 35.6410143197085,
"lng" : 139.7121041197085
}
}
},
"place_id" : "ChIJPwj22RWLGGARAf6hDZkG7aQ",
"types" : [ "postal_code" ]
}
],
"status" : "OK"
}