# pcjclass Musicplay(object): id=None def __new__(cls, *args, **kwargs): if cls.id is None: cls.id=super().__new__(cls) #new是一个静态方法。所以要传cls参数 return cls.id def __init__(self): print("音乐初始化中........") music1=Musicplay()music2=Musicplay()print(music1)print(music2)
原文地址:https://www.cnblogs.com/pcjbk/p/11279765.html
时间: 2024-10-23 08:42:47