AttributeError: type object 'Getset' has no attribute 'uid'

问题描述 投票:0回答:0
class Getset:
    lname:str
    uid:int

    @classmethod
    def get_lname(cls):
        return cls.lname
    
    @classmethod
    def set_lname(cls,lname:str):
        cls.lname = lname
    
    @classmethod
    def get_uid(cls):
        return cls.uid
    
    @classmethod
    def set_uid(cls,uid:int):
        cls.uid = uid

i 已经声明了

gs = Getset()
并使用了
gs.get_uid()
。有时有效,有时无效

python fastapi class-method static-variables
© www.soinside.com 2019 - 2024. All rights reserved.