a = {'a':'bb'} b = {'b':'cc'} dict(a,**b) 不会报错
dict(a,{'b':'cc'})
为啥报错呢
1
xgzxy 2018-03-09 22:50:04 +08:00
"""
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2) # (copied from class doc) """ |
2
SingeeKing 2018-03-09 23:00:40 +08:00
dict(a,**b) = dict(a, **{'b': 'cc'}) = dict(a, b='cc') = {'a': 'bb', 'b': 'cc'}
|