不实例化一个 class 的时候使用它的property

 1 class A:
 2     @property
 3     def name(self):
 4         return "123"
 5 
 6 
 7 print(A.name)  # <property object at 0x10d54cf98>
 8 
 9 
10 class B(type):
11     @property
12     def name(cls):
13         return "123"
14 
15 
16 print(B.name)  # <property object at 0x10da69688>
17 
18 
19 class C(metaclass=B): ...
20 
21 
22 print(C.name)  # 123
原文地址:https://www.cnblogs.com/twotigers/p/9370856.html