在处理标注数据文件的时候,需要用python来读写json文件。常用的读写方式如下:
# read the local json file
with open('dict.json', 'r') as obj:
dict = json.load(obj)
# write the dict to local json file
with open('test.json', 'w') as obj:
json.dump(dict, obj, indent=2)
在写入json文件的时候,需要加上参数"indent=2"以避免所有数据输出到同一行。
版权声明:本文为u013685264原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。