0
4

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

pythonでjsonの保存

0
Posted at

Python, Requestsの使い方 | note.nkmk.me
天気予報 API(livedoor 天気互換)

weather_request.py
import requests
import json

def main():
    url = "https://weather.tsukumijima.net/api/forecast/city/130010"
    res = requests.get(url)
    json_text = json.dumps(res.json())
    with open("f.txt", "w", encoding="utf-8") as f:
        f.write(json_text)
    json_obj = json.loads(json_text)  # ロード
    print(json_obj)
    # {'publicTime': '2020-12-12T17:00:00+09:00', 'publicTime_format': '2020/12/12 17:00:00', 'title': '東京都 東京 の天気', '

if __name__ == '__main__':
    main()
0
4
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
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?