剑指offer python版 实现单例模式

class singleTon(object):
    def __init__(self,x):
        self.val=x
        
single2=singleTon(2)

a=single2
b=single2

print(a==b)

print(a.val)

a.val=334

print(b.val)

 

posted @ 2018-10-25 09:14  findtruth123  阅读(169)  评论(0编辑  收藏  举报