gpt4 book ai didi

python - 获取字典中匹配键的值

转载 作者:太空宇宙 更新时间:2023-11-04 06:52:32 24 4
gpt4 key购买 nike

<分区>

我有两个 OrderedDict 字典,我想检索两个字典中匹配键的值:

>>> from collections import OrderedDict
>>> d1 = OrderedDict()
>>> d2 = OrderedDict()

>>> d1["A"] = 2
>>> d1["B"] = 3
>>> d1["C"] = 2

>>> d2["D"] = 90
>>> d2["B"] = 11
>>> d2["C"] = 25

>>> # search both dicts and output values where key matches

(3, 11)
(2, 25)

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