|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
class Player:
instance = None
init_flag = False
def __new__(cls,yy):
def __init__(self):
if Player.init_flag:
return
print("初始化")
Player.init_flag = True
p1 = Player()
print(p1)
p2 = Player()
print(p2)
File "C:\Users\tlan2\PycharmProjects\david\jj.py", line 8
def __init__(self):
^
IndentationError: expected an indented block
Process finished with exit code 1
怎么解决
- class Player:
- instance = None
- init_flag = False
- def __new__(cls,yy):
- pass
- def __init__(self):
- if Player.init_flag:
- return
- print("初始化")
- Player.init_flag = True
复制代码
|
|