【发布时间】:2019-08-28 07:47:32
【问题描述】:
我有一个 json 文件,我正在加载它以便通过某个名为“sender_id”的键进行过滤。我似乎可以过滤任何其他键,但是在过滤“sende_id”时会导致 KeyError: 'sender_id'
我的python脚本如下:
import json_lines
with open('specifications.jsonl', 'rb') as f:
for item in json_lines.reader(f):
print(item["sender_id"])
我的 jsonlines 文件示例如下:
{"status": "Inactive", "no_of_rejected_submissions": 0, "name":
"multi senders 6", "data_type": "acute", "author": "JKS",
"
【问题讨论】:
标签: python json python-3.x python-2.7 jsonlines