2015/09/22

Python 3.5 取得JSON檔案

# -*- coding: utf-8 -*-

import json
from urllib import request
url = "http://data.kaohsiung.gov.tw/Opendata/DownLoad.aspx?Type=2&CaseNo1=AP&CaseNo2=17&FileType=2&Lang=C&FolderType="
data = request.urlopen(url).read().decode("utf-8")

print (json.loads(data))

執行結果:


參考資料:
https://docs.python.org/3.5/library/urllib.request.html#module-urllib.request
https://docs.python.org/3.5/library/json.html