hutils
hutils copied to clipboard
重写TupleEnum的__str__方法,让返回value
class SecretEnum(TupleEnum): SECRET = "secret", "敏感" NO_SECRET = "no_secret", "非敏感"
>>>print(str(SecretEnum.SECRET)) >>>SecretEnum.SECRET
重写__str__: class TupleEnum: def __str__(self): return self.value
>>>print(str(SecretEnum.SECRET)) >>>"secret"