Zentopia
12/27/2017 - 7:56 AM

python json 文件解析

python json 文件解析

import json

with open('train_to_mark_splitP40.json', 'r', encoding='utf-8-sig') as f:
    data = json.load(f)

data = data['rasa_nlu_data']
for example in data['common_examples']:
    print(example['text'])
    print(example['intent'])
    for entity in example['entities']:
        print(entity['start'])
        print(entity['end'])
        print(entity['value'])
        print(entity['entity'])