Skip to main content
 首页 » 编程设计

python之如何使用静态方法初始化静态变量

2024年10月24日10mayingbao

<分区>

class One: 
    i = One.get(9) 
    @staticmethod 
    def get(val): 
        pass 

我尝试使用静态方法初始化静态变量,但上面的代码引发了这个错误:

NameError: name 'One' is not defined 

如何在 Python 中使用静态方法初始化静态变量?