使用Python,我将json文档保存到单独的行中,如下所示:
from bson import json_util # pymongo
with open('test.json','ab') as f:
for document in documents:
f.write(json_util.dumps(document)+'\n')
然后像这样阅读:
with open('test.json') as f:
for line in f:
document = json_util.loads(line)
简单易用让我觉得一定有问题吗?这就是linejson,又名jsonlines吗?
最佳答案
是的,这就是它的全部.
原文链接:https://www.f2er.com/python/438388.html