那我怎么改A类?第一个打印:
{"s":1, "b":2}
第二个
{"s":3, "b":2}
但我想我应该和第一个一样
class A():
def __init__(self, **kwargs):
self.g =""
for key, value in kwargs.items():
setattr(self, key, value)
class B():
def __init__(self, classA):
self.f = classA.g
a = A(g={"s":1, "b":2})
print (a.g)
b = B(a)
b.f["s"]=3
print (a.g)