Avatar ·

如何在 Python 中创建类的静态属性?

📁 python, 错误

我尝试这样做:

class Chatcodes:  _chat = 'CHT'  @property  def chat(self):  return self._chat

如果我这样使用:

print(Chatcodes.chat + 'ANY_STR')

则会出现错误:

unsupported operand type(s) for +: 'property' and 'str'

如何创建静态属性?