python3.6 code :
class User(object):
def __new__(cls, *args, **kwargs):
print('new called')
return super(User, cls).__new__(cls)
def __init__(self,name,age):
print('init called')
self.name = name
self.age = age
user = User('wangcai',12)
print(user.age)
class User(object):
def __new__(cls, *args, **kwargs):
print('new called')
return super(User, cls).__new__(cls)
def __init__(self,name,age):
print('init called')
self.name = name
self.age = age
user = User('wangcai',12)
print(user.age)
2017-05-26
全是专业术语,头疼!听不懂,形象的比喻太少了,好难理解类和对象以及属性和方法之间的关系还有逻辑,对于小白来说,还是好难,呜呜~~~~(>_<)~~~~
2017-05-23