In [3]: class T(object):
...: def __init__(self, d=dict(a='111')):
...: print(d.pop('a'))
...:
In [4]: t1 = T()
111
In [5]: t2 = T()
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-5-0432c2295f2f> in <module>
----> 1 t2 = T()
<ipython-input-3-e66c30fecc13> in __init__(self, d)
1 class T(object):
2 def __init__(self, d=dict(a='111')):
----> 3 print(d.pop('a'))
4
KeyError: 'a'
这说明python参数的默认值是该类跨instance共享的,如果是object最好不要进行修改,如果需要修改请先复制。