chatterbot 和 Django 集成中的statement.text 返回
{'text': u'How are you doing?', 'created_at': datetime.datetime(2017, 2, 20, 7, 37, 30, 746345, tzinfo=<UTC>), 'extra_data': {}, 'in_response_to': [{'text': u'Hi', 'occurrence': 3}]}
我想要一个文本属性的值,以便它打印你好吗?
最佳答案
chatterbot
返回 json
对象(dict
),因此您可以使用字典
操作,如下所示
[1]: data = {'text': u'How are you doing?', 'created_at': datetime.datetime(2017, 2, 20, 7, 37, 30, 746345, tzinfo=<UTC>), 'extra_data': {}, 'in_response_to': [{'text': u'Hi', 'occurrence': 3}]}
[2]: data['text'] or data.get('text')[this approch is good].
关于json - Chatterbot 和 Django 集成中获取 JSON 的属性值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42406109/