在處理標註數據文件的時候,需要用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"以避免所有數據輸出到同一行。