python——单例

单例

#代码A
# -*- coding:gb2312 -*-
class Dog (object):
    def __init__(self):
        print("-----init方法-----")
    def __del__(self):
        print("-----del方法-----")
    def __str__(self):
        #print("-----str方法-----")
        return ("-----str方法-----")
    def __new__(cls):
        print("-----new方法-----")
        #return object.__new__(cls)     
xtq = Dog()
posted @ 2020-04-17 18:20  两颗心的章鱼  阅读(126)  评论(0)    收藏  举报