开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜