简体   繁体   English

如何在已加载的json文件中添加json行?

[英]How to append a json line to a loaded json file?

I am writing Python code. 我正在编写Python代码。 I loaded a json file. 我加载了一个json文件。

with open('..\config_4099.json', "r") as fid:
    jaySon = json.load(fid)

It's a flat json structure, so no internal elements to append to. 这是一个平面json结构,因此没有要附加的内部元素。 Just need to tack onto the bottom the piece in curlies: 只需将卷发钉在底部即可:

jaySon.append({'pluginInputs': "PluginInputs"})

It's complaining about dictionaries. 它在抱怨字典。

What's the best way to do this? 最好的方法是什么?

对于字典,请使用update

jaySon.update({'pluginInputs': "PluginInputs"})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM