data = {"books": [
{
"book": "Three Blind Mice",
"author": "John Ivimey",
"price": 2
},
{
"book": "Wizard of Oz",
"author": "Frank Baum",
"price": 3
},
]
}
我错误“列表索引必须是整数或切片,而不是str”
for i in data:
print("book: {}".format(data[i]["book"]))
如何像这样打印它:
1. book: Three Blind Mice
author: John Ivimey
price: 2
2. book: "Wizard of Oz"
author: "Frank Baum"
price: 3
我也想将其存储到一个类中以供以后参考。请帮助