我data.json
是解析JSON數據
{"a":[{"b":{"c":{ "foo1":1, "foo2":2, "foo3":3, "foo4":4}}}],"d":[{"e":{"bar1":1, "bar2":2, "bar3":3, "bar4":4}}]}
我能同時列出key/pair
值。我的代碼是:
#! /usr/bin/python
import json
from pprint import pprint
with open('data2.json') as data_file:
data = json.load(data_file)
pprint(data["d"][0]["e"])
這給了我:
{u'bar1': 1, u'bar2': 2, u'bar3': 3, u'bar4': 4}
但我只想沒有任何像這樣的quotes
和u
顯示keys
:
bar1, bar2, bar3, bar4
任何人都可以提出什麼嗎?它不一定只在Python中,也可以在shell腳本中。
不需要使用'keys'。 – thefourtheye
不需要'鑰匙' – user227666