#方便不占用内存,缺点最后写完后会多一个逗号,要自己手动删除
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("[")
浙公网安备 33010602011771号