Python:
from datetime import datetime as dt
class Player:
__LVL, __HEALTH = 1, 100
__slots__ = ['__lvl', '__health', '__born']
def __int__(self):
self.__lvl = Player.__LVL
self.__health = Player.__HEALTH
self.__born = dt.now()
def get_lvl(self):
return self.__lvl
def set_lvl(self, numeric):
self.__lvl += numeric
x = Player()
print(x.get_lvl())
Ошибка:
Traceback (most recent call last):
File "D:\Pyton PyChram Projects\main.py", line 21, in <module>
print(x.get_lvl())
File "D:\Pyton PyChram Projects\main.py", line 15, in get_lvl
return self.__lvl
AttributeError: 'Player' object has no attribute '_Player__lvl'. Did you mean: '_Player__LVL'?
Последнее редактирование модератором: