python - 如何使用理解从 python 中的字典中创建值列表
问题描述
{'AAPL': (175.96, 'Apple Inc'),
'GOOGL': (0.00475, 'Alphabet Inc'),
'TVIX': (0.0045, 'Credit Suisse AG')}
如何提取以下列表:Apple In
、、Alphabet Inc
和Credit Suisse AG
解决方案
使用此列表理解:
print([i[1] for i in yourdictionary.values()])
输出:
['Apple Inc', 'Alphabet Inc', 'Credit Suisse AG']
PS 更改yourdictionary
为您的字典的实际名称。
推荐阅读
- python - KeyError: 1 在使用 SP_LIME 和 Lightgbm
- r - K-means 对相同数据迭代 10 次
- adonis.js - RuntimeException: E_MISSING_CONFIG Adonis.js
- python - 谁在 Django 中显示图像
- ionic-framework - Ionic 5 警报按钮都是大写的
- css - 如何禁用特定字段的 CSS
- mysql - 更新后使用触发器在 MySql 表中插入 RowData
- r - 在闪亮的上下文中ggplot2中的标签问题
- android - 如何访问 CardView 上的弹出菜单
- typescript - RxJS 中点击运算符的输出问题