开发者

Parsing the content of a 'Requests' call only shows some json data

开发者 https://www.devze.com 2023-04-12 16:56 出处:网络
To start here is some code: import requests import json url = r\'http:\\\\some.url\' p = requests.post(url)

To start here is some code:

import requests
import json

url = r'http:\\some.url'


p = requests.post(url)
print p.status_code
data = json.load(p)
for entry in data:
    print entry

print data

The output of this program is as follows (note values are sanitized):

200
a
{"a":"b"}

Is there a way to get value "b" applied to a variable? Since the post will always return {"a"开发者_Go百科:"b"}, I don't really care what "a" is, since it is basically a constant.


Assuming Python 2.x:

>>> x = {"a":"b"}
>>> x.values()
['b']
>>> x.values()[0]
'b'
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号