小编Pet*_*ter的帖子

添加两个词典中的值

dict1 = {a: 5, b: 7}
dict2 = {a: 3, c: 1}

result {a:8, b:7, c:1}
Run Code Online (Sandbox Code Playgroud)

我怎样才能得到结果?

python algorithm merge dictionary python-3.x

7
推荐指数
2
解决办法
7103
查看次数

如何从Python中的字典中获取键值?

d[key] = value
Run Code Online (Sandbox Code Playgroud)

但如何从价值中获取钥匙?

例如:

a = {"horse": 4, "hot": 10, "hangover": 1, "hugs": 10}
b = 10

print(do_something with 10 to get ["hot", "hugs"])
Run Code Online (Sandbox Code Playgroud)

python

4
推荐指数
2
解决办法
3万
查看次数

标签 统计

python ×2

algorithm ×1

dictionary ×1

merge ×1

python-3.x ×1