我很难找到解决方案:
dict_a = {'deecf4bc': 'my_machine'}
dict_b = {'deecf4bc': 'blade-000'}
dict_ab = {'deecf4bc':'my_machine', ' : ', u'blade-000'}
这是我的口述稿,上面写着:
for key, value in dict_X():
print(key, ' : ', value)
这些dict来自像Nova或Ironic这样的Python库 我想在第一列的基础上创建另外两个dict,但我失败了,我尝试了以下方法:
x = dict(a.items() + b.items())
还有更多
有人建议:How do I merge two dictionaries in a single expression in Python (taking union of dictionaries)?
它不工作,因为它显示的内容与dict_b相同
编辑:当我重写dicts时,在我看来,我想要的数据的最终形式类似于一个键和两个值,有可能吗
多谢各位
要合并词汇表,请执行以下操作:
查看编辑注释,要将2 dict的值组合在一起,可以执行以下操作
相关问题 更多 >
编程相关推荐