MemoryError using json.dumps()

前端 未结 2 982
醉酒成梦
醉酒成梦 2020-12-18 07:21

I would like to know which one of json.dump() or json.dumps() are the most efficient when it comes to encoding a large array to json format.

<
2条回答
  •  再見小時候
    2020-12-18 07:35

    You can simply replace

    f.write(json.dumps(mytab,default=dthandler,indent=4))
    

    by

    json.dump(mytab, f, default=dthandler, indent=4)
    

    This should "stream" the data into the file.

提交回复
热议问题