我在我的 Python 代码中定义了一个 URL,我需要读取它并将其保存在一个 json 文件中,然后将它们保存在一个列表或字典中。在我的代码中,我阅读并打印它们。另外,我想知道我的代码中是否有任何问题,例如 post 方法或从 URL 读取键值对?
\t
答案 0 :(得分:0)
读取元数据。 以您的方式排列键和值以制作字典。
#Save extracted content to dictionary/list
myjsondata={}
for i in data:
for key, value in i.iteritems():
if key == 'uid':
print key, value
myjsondata[key]=value
#Save your dictionary content to json file
with open('saved_json_file_1.json', 'w') as saveFile:
saveFile.write(json.dumps())