如何在Python中创建类的静态属性?
📁 python, 错误
我尝试这样:
class ChatCodes: _chat = 'cht' @property def chat(self): retu self._chat如果这样使用:
print(ChatCodes.chat + 'any_str')会出现错误:
unsupported operand type(s) for +: 'property' and 'str'
如何正确创建静态属性?
📁 python, 错误
我尝试这样:
class ChatCodes: _chat = 'cht' @property def chat(self): retu self._chat如果这样使用:
print(ChatCodes.chat + 'any_str')会出现错误:
unsupported operand type(s) for +: 'property' and 'str'
如何正确创建静态属性?