如何使用python请求和处理JSON? [英] How do I request and process JSON with python?

查看:95
本文介绍了如何使用python请求和处理JSON?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将GET请求发送到我知道的URL,该URL使用python以JSON的形式返回数据.

I am trying to send a GET request to a URL that I know returns data in the form of JSON using python.

我想知道如何将该请求发送到http://someurl/path/to/json,以及如何解析它-最好是发送给python dict.

I would like to know how to send this request to http://someurl/path/to/json, and how to parse it - preferably to a python dict.

推荐答案

对于任何对URL的请求,您可能想查看

For anything with requests to URLs you might want to check out requests. For JSON in particular:

>>> import requests
>>> r = requests.get('https://github.com/timeline.json')
>>> r.json()
[{u'repository': {u'open_issues': 0, u'url': 'https://github.com/...

这篇关于如何使用python请求和处理JSON?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆