本文介绍了如何使用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的请求,您可能想查看请求.特别是对于JSON:
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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!