我正在尝试执行类似于以下代码的操作,而不是像代码中的最后一行那样打印, 我正在寻找显示为字典列表的输出。
import json
studentsList = []
print("Started Reading JSON file which contains multiple JSON document")
with open('students.txt') as f:
for jsonObj in f:
studentDict = json.loads(jsonObj)
studentsList.append(studentDict)
print("Printing each JSON Decoded Object")
for student in studentsList:
print(student["id"], student["name"], student["class"], student["email"]) # Expecting output to show as list of dicts
谢谢