标签:one assm log none 单例模式 div nbsp instance span
class SingleObj(): __singleobj=None @classmethod def get_singleinstance(cls): if not cls.__singleobj: cls.__singleobj=SingleObj() return cls.__singleobj obj1=SingleObj.get_singleinstance() print(obj1) obj2=SingleObj.get_singleinstance() print(obj2) obj3=SingleObj.get_singleinstance() print(obj3) ##ret <__main__.SingleObj instance at 0x00000000057B1E88> <__main__.SingleObj instance at 0x00000000057B1E88> <__main__.SingleObj instance at 0x00000000057B1E88>
标签:one assm log none 单例模式 div nbsp instance span
原文地址:http://www.cnblogs.com/howhy/p/7787707.html