【问题标题】:How to use python script to download JSON from the net using API [closed]如何使用 python 脚本使用 API 从网上下载 JSON [关闭]
【发布时间】:2020-05-08 12:29:12
【问题描述】:

我是 python 新手。 谁能告诉我如何从 python 中的给定 API 下载 JSON 文件,然后使用 mako 或 jinja 保存为 HTML?

  1. 使用python脚本通过API从网上下载JSON。

【问题讨论】:

    标签: python json mako


    【解决方案1】:
    import requests
    requests.get(URL).json()
    

    【讨论】:

      【解决方案2】:

      您使用 requests 模块通过以下代码获取 json

      import requests
      url = "http://samples.openweathermap.org/data/2.5/weather?q=London,uk&appid=b6907d289e10d714a6e88b30761fae22"
      res = requests.get(url)
      if res.ok:
          res.json()
      

      如需更多资源,您可以关注link

      【讨论】:

        猜你喜欢
        • 2012-02-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-09-21
        • 2016-05-13
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多