Python json.loads shows ValueError: Extra data

后端 未结 9 898
甜味超标
甜味超标 2020-11-22 16:21

I am getting some data from a JSON file \"new.json\", and I want to filter some data and store it into a new JSON file. Here is my code:

import json
with ope         


        
9条回答
  •  轮回少年
    2020-11-22 16:52

    If you want to solve it in a two-liner you can do it like this:

    with open('data.json') as f:
        data = [json.loads(line) for line in f]
    

提交回复
热议问题