我只想问一些关于json和python的问题。在
如果我是正确的,那么将StringIO加载到json将导致它有一个u'。在
例如,在json库中:>>> from StringIO import StringIO
>>> io = StringIO('["streaming API"]')
>>> json.load(io)
结果到
^{pr2}$
那么如何解析这些数据呢?为了让我整理数据
看起来像这样?我有我想要解析的数据。在{u'brix': {u'Nov 29, 2017 11:20:15 PM': {u'Checklist': {u'Coffee tray
with 3 coffee sticks, 3 creamer, 3 white sugar, 3 brown sugar, 1 equal
or sweetener, 3 lipton tea, 2 mineral water, 3 cocktail napkin ?':
u'No', u'Luggage bench fabric top is clean': u'No', u'1 facial tissue
in a tissue box': u'No', u'Towel Reminder': u'No', u'1 pringles, 1
cashew nut, 1 cup noodles (placed in the coffee tray on the writing
desk)?': u'No',
在阅读了一些关于json的文章后,我发现这可能是一个StringIO而不是json。我这么做是愚蠢的json.loads当我把它装上的时候。我所要做的就是对所有这些数据进行分类,使其在网络上正确显示。在
我该怎么做?我是否要先将这些解码为json以便它变成类似{
"maps":[
{"id":"blabla","iscategorical":"0"},
{"id":"blabla","iscategorical":"0"}
],
"masks":
{"id":"valore"},
"om_points":"value",
"parameters":
{"id":"valore"}
}
然后用这个从中得到一个值?在data["maps"][0]["id"] # will return 'blabla'
data["masks"]["id"] # will return 'valore'
data["om_points"] # will return 'value'
不管怎样,我不知道该怎么做,我几乎什么都试过了,这些例子来自其他问题。在
下面是我的一些代码:result1 = firebase.get('/Rooms/Room1/2017-11-29/Inspection/Scan-in/Inspector/', None)
result2 = firebase.get('/Rooms/Room1/2017-11-29/Inspection/Scan-out/Inspector/', None)
print result1["brix"]
Firebase应该返回一个json文件。哈哈,但我的不管用。在
非常感谢那些愿意向我澄清的人。在