【发布时间】:2022-11-12 17:48:28
【问题描述】:
data =
{'gems': [{'name': 'garnet', 'colour': 'red', 'month': 'January'},
{'name': 'emerald', 'colour': 'green', 'month': 'May'},
{'name': "cat's eye", 'colour': 'yellow', 'month': 'June'},
{'name': 'sardonyx', 'colour': 'red', 'month': 'August'},
{'name': 'peridot', 'colour': 'green', 'month': 'September'},
{'name': 'ruby', 'colour': 'red', 'month': 'December'}]}
如何创建颜色列表,然后只找到红色的月份?
我已经尝试过,如果,但我不断收到错误消息
字符串索引必须是整数
【问题讨论】:
标签: python json python-3.x list dictionary