AttributeError:' dict'对象没有属性' itervalues'

时间:2018-04-21 14:26:23

标签: python-3.x

为什么python 3中存在属性错误。 有什么可以取代它?

d1 = {'a':1,'b':2}
d2 = {'c':4,'d':5}
def switch(d1,d2):
    dout = {}

    for d1key,d2val in zip(d1,d2.itervalues):
        dout[d1key] = d2val

    return dout

switch(d1,d2)

---------------------------------------------------------------------------


AttributeError: 'dict' object has no attribute 'itervalues

0 个答案:

没有答案