如果您从某些API获取这些数据,那么很可能您将它们作为字符串获取。因此,让我们将您的数据制作成这样的字符串:
js = '''[{"word":"handsome","phonetic":"/Ëhæn.sÉm/","phonetics":[{"text":"/Ëhæn.sÉm/","audio":"https://api.dictionaryapi.dev/media/pronunciations/en/handsome-uk.mp3","sourceUrl":"https://commons.wikimedia.org/w/index.php?curid=9021972","license":{"name":"BY 3.0 US","url":"https://creativecommons.org/licenses/by/3.0/us"}},{"text":"/Ëhæn.sÉm/","audio":"https://api.dictionaryapi.dev/media/pronunciations/en/handsome-us.mp3","sourceUrl":"https://commons.wikimedia.org/w/index.php?curid=1648256","license":{"name":"BY-SA 3.0","url":"https://creativecommons.org/licenses/by-sa/3.0"}}],"meanings":[{"partOfSpeech":"verb","definitions":[{"definition":"To render handsome.","synonyms":[],"antonyms":[]}],"synonyms":[],"antonyms":[]},{"partOfSpeech":"adjective","definitions":[{"definition":"(of people, things, etc) Having a good appearance; good-looking.","synonyms":[],"antonyms":[],"example":"a handsome garment, house, tree, or horse"},{"definition":"Good, appealing, appropriate.","synonyms":[],"antonyms":[]},{"definition":"Generous or noble in character.","synonyms":[],"antonyms":[],"example":"Handsome is as handsome does."},{"definition":"Ample; moderately large.","synonyms":[],"antonyms":[],"example":"a handsome salary"},{"definition":"(said of things and people) Dexterous; skillful.","synonyms":[],"antonyms":[]}],"synonyms":["hefty","substantial","good-looking","pretty"],"antonyms":[]}],"license":{"name":"CC BY-SA 3.0","url":"https://creativecommons.org/licenses/by-sa/3.0"},"sourceUrls":["https://en.wiktionary.org/wiki/handsome"]}]'''
现在
import json
jlist = json.loads(js)
print(jlist[0]["meanings"])
然而,如果您已经处理了API响应,并且具有问题中所示的数据,那么它只是:
js = [{"word":"handsome","phonetic":"/Ëhæn.sÉm/","phonetics":[{"text":"/Ëhæn.sÉm/","audio":"https://api.dictionaryapi.dev/media/pronunciations/en/handsome-uk.mp3","sourceUrl":"https://commons.wikimedia.org/w/index.php?curid=9021972","license":{"name":"BY 3.0 US","url":"https://creativecommons.org/licenses/by/3.0/us"}},{"text":"/Ëhæn.sÉm/","audio":"https://api.dictionaryapi.dev/media/pronunciations/en/handsome-us.mp3","sourceUrl":"https://commons.wikimedia.org/w/index.php?curid=1648256","license":{"name":"BY-SA 3.0","url":"https://creativecommons.org/licenses/by-sa/3.0"}}],"meanings":[{"partOfSpeech":"verb","definitions":[{"definition":"To render handsome.","synonyms":[],"antonyms":[]}],"synonyms":[],"antonyms":[]},{"partOfSpeech":"adjective","definitions":[{"definition":"(of people, things, etc) Having a good appearance; good-looking.","synonyms":[],"antonyms":[],"example":"a handsome garment, house, tree, or horse"},{"definition":"Good, appealing, appropriate.","synonyms":[],"antonyms":[]},{"definition":"Generous or noble in character.","synonyms":[],"antonyms":[],"example":"Handsome is as handsome does."},{"definition":"Ample; moderately large.","synonyms":[],"antonyms":[],"example":"a handsome salary"},{"definition":"(said of things and people) Dexterous; skillful.","synonyms":[],"antonyms":[]}],"synonyms":["hefty","substantial","good-looking","pretty"],"antonyms":[]}],"license":{"name":"CC BY-SA 3.0","url":"https://creativecommons.org/licenses/by-sa/3.0"},"sourceUrls":["https://en.wiktionary.org/wiki/handsome"]}]
print(js[0]["meanings"])