# -*- coding: utf-8 -*-
#在序列化前 魔法属性已经被构造出来。所以里面的字典得不到更新
class A():
def __init__(self, a):
self.d = a
data = {}
wrong = A(data)
data = {1:2}
print wrong.d
right = A(data)
data.update({1:2})
print right.d
{}
{1: 2}
# -*- coding: utf-8 -*-
#在序列化前 魔法属性已经被构造出来。所以里面的字典得不到更新
class A():
def __init__(self, a):
self.d = a
data = {}
wrong = A(data)
data = {1:2}
print wrong.d
right = A(data)
data.update({1:2})
print right.d
{}
{1: 2}