我想避免使用 update() 方法,并且我读到可以使用“+”操作数将两个字典合并到第三个字典中,但是在我的 shell 中发生的是:
>>> {'a':1, 'b':2}.items() + {'x':98, 'y':99}.items()
Traceback (most recent call last):
File "<pyshell#84>", line 1, in <module>
{'a':1, 'b':2}.items() + {'x':98, 'y':99}.items()
TypeError: unsupported operand type(s) for +: 'dict_items' and 'dict_items'
>>> {'a':1, 'b':2} + {'x':98, 'y':99}
Traceback (most recent call last):
File "<pyshell#85>", line 1, in <module>
{'a':1, 'b':2} + {'x':98, 'y':99}
TypeError: unsupported operand type(s) for +: 'dict' and 'dict'
我怎样才能让它工作?