gpt4 book ai didi

python - 通过 python 中的键过滤列表中字典项的值

转载 作者:太空宇宙 更新时间:2023-11-04 08:04:30 25 4
gpt4 key购买 nike

<分区>

我在 python 中有一个这样的列表:

x = [{'A': 1, 'B': 2}, {'A': 3, 'B': 4}, {'A': 5, 'B': 6}]

它的成员是 Dictionary 项。我想过滤列表以获取此列表:

X = [1, 3, 5]

有没有像 x[0:2]['A'] 这样的神奇命令来过滤列表?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com