给定一个如下所示的JSON文件:
"foobar": [
{
"a": "true",
"b": 1,
"c": 1234,
"d": 9,
"e": "red"
},
{
"a": "false",
"b": 2,
"c": 2345,
"d": 7,
"e": "green"
},
{
"a": "whocares",
"b": 3,
"c": 3456,
"d": 5,
"e": "blue"
}
]
有没有可能在没有循环的情况下,检查其中任何一个中是否存在“blue”?你知道吗
import simplejson
j = json.loads(superfile().text)
if "blue" in j['foobar'][ANYONE]['e']
正如@jonrsharpe提到的,您最好的选择可能是使用^{}
或者
相关问题 更多 >
编程相关推荐