python - 如何使用 python 只选择我需要的列
问题描述
ml = MonkeyLearn('2d14ec2555abc7f9e2aefee982e212d9091e310a')
data = ['I am excellent']
result = ml.classifiers.classify(model_id, data)
t = result.body[0]
print(t)
{'text': 'Good', 'external_id': None, 'error': False, 'classifications': [{'tag_name': 'Positive', 'tag_id': 122921383, 'confidence': 0.983}]}
我在数组数组中有一个列表,我怎样才能从这个数据中只删除“分类”列,这个数据在数组中,我只想要所需的输出:
Classification : Tag_name : Positive
Confidence : 0.983
解决方案
您可以使用此代码 -
t = {'text': 'Good', 'external_id': None, 'error': False, 'classifications': [{'tag_name': 'Positive', 'tag_id': 122921383, 'confidence': 0.983}]}
classifications = t['classifications']
推荐阅读
- c++ - 在 C++ 中使用 read() 从文件中读取
- c++ - 指针)是否有可能(ptr + 1)已经被占用?
- phpstorm - 运行调试器时出现 PhpStorm 错误:SyntaxError: Unexpected token = (on class property)
- windows - Visual Studio 2017 Professional 未显示 Windows 驱动程序项目的选项
- reactjs - react, useEffect: 可以用全局变量作为因变量吗?
- django - 动态内容的 Django 模板和数学表达式
- java - InvalidDataAccessApiUsageException:分离的实体传递给持久化
- javascript - 如何在 npm 上发布 ckeditor 经典版本的自定义版本?
- matlab - Matlab poly() 函数的奇怪行为
- wordpress - 无法在 Wordpress 中设置社交链接