在处理标注数据文件的时候,需要用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"以避免所有数据输出到同一行。