【发布时间】:2016-07-21 05:38:03
【问题描述】:
我基本上是使用update方法合并两个字典。问题是当我合并python shell 时它可以工作,但在执行时不在文件中。
v = {'customer_id': '9000', 'customer_name': 'Apple Inc'}
b = {"a": "b"}
print v.update(b)
上面的输出是None
但它在 shell 中工作。我的愚蠢错误是什么?谢谢你
【问题讨论】:
-
在 shell 中工作 是什么意思?即使输出
None。 -
@JasonEstibeiro 检查图片
-
那是因为你打印了
v的值。v.update(b)的输出什么都没有。 -
知道了。谢谢大家:)你们的耐心
标签: python dictionary