# Opening JSON file
f = open('my_json.json')
# returns JSON object as a dictionary
data = json.load(f)
# extract values
i = data['segments'][3]['words']
print(i)
Я пытаюсь понять, как получить определенное значение из файла JSON в Python. Как мне распечатать значения «текст» и «начало» из первой записи словаря? [code]# Opening JSON file f = open('my_json.json')
# returns JSON object as a dictionary data = json.load(f)
# extract values i = data['segments'][3]['words']
print(i) [/code] Дает мне [code][{'text': 'What', 'start': 6.98, 'end': 7.14, 'confidence': 0.997}, {'text': 'about', 'start': 7.14, 'end': 7.3, 'confidence': 0.998}, {'text': 'you,', 'start': 7.3, 'end': 7.46, 'confidence': 0.414}, {'text': 'Melissa?', 'start': 7.54, 'end': 7.65, 'confidence': 0.929}] [/code] В конечном итоге я хочу просмотреть все значения и получить текст и начало каждого слова. Спасибо