python - 如何从字典python列表中获取所有id
问题描述
我有以下来自 json 文件的结果。我想从字典列表中获取所有 id
result = {
"response": [{
"1d": 1,
"name": "jhon"
},
{
"1d": 2,
"name": "tom"
},
{
"1d": 3,
"name": "peter"
}
]}
预期结果:[1, 2, 3]
解决方案
print ([value['1d'] for value in result['response'] ])
推荐阅读
- python - 如何仅从加载的图像的一部分制作 pygame 表面对象?
- python-3.x - 在 Python 中处理大数字和大数组时提高速度
- javascript - 无法在“AudioNode”上执行“connect”
- python - 在 Entry() 框中显示选定文件路径的问题 - Python Tkinter
- python - 在 Windows 10 上的 pycharm 中安装 scrapy 时出现未知错误
- react-native - 文本下推其他文本
- python - 连接 3 个数据框更改原始的列类型
- yocto - meta-openembedded 的 meta-oe 与 Poky 的 meta
- visual-studio-code - Visual Studio 代码上的重复“添加文件夹”问题
- javascript - 对对象/列表数组进行双重排序