python 对象管理

在这里插入图片描述

**class User:
    def __new__(cls, *args, **kwargs):
      print("this is new method=====")
      instance=object.__new__(User)
      return instance

    def __init__(self,name,age):
        self.name=name
        self.age=age
    print("this is init methond==========")
User("zhangsan",18)**

在这里插入图片描述
在这里插入图片描述
关于is 与等号
等号判断内容是否相同
is判定内存是否相同
eg
a=1
b=1
ab
a is b
结果都是Ture
a=1
b=1.0
a
b
a is b
结果:
a==b 是Ture
a is b 是 False

猜你喜欢

转载自blog.csdn.net/guotianxiu1234/article/details/88990908