#方便不佔用記憶體,缺點最後寫完後會多一個逗號,要自己手動刪除
def begin_write_json():
with open('file.json', "w", encoding="utf-8") as f:
f.write("[")
def write_josn(items:dict):
with open('file.json', "a", encoding="utf-8") as f:
# f.write(json.dumps(items,ensure_ascii=False,sort_keys=True))
f.write(json.dumps(items, ensure_ascii=False))
f.write(",")
def last_write_josn():
with open('file.json', "a", encoding="utf-8") as f:
f.write("[")