Jil*_*loc 39 python enums enumeration
有没有标准方法可以获得 Enumeration names by value?
Enumeration names by value?
一个例子:
class Example(enum.Enum): one = 1 two = 2 ex_variable = 1
给定ex_variable,我可以获取Example.one.name中包含的字符串吗?
ex_variable
Nil*_*ner 72
>>> Example(1).name 'one'
另见Python文档.
AKS*_*AKS 6
以编程方式访问枚举的成员:
>>> Example(ex_variable).name 'one'
归档时间:
9 年,10 月 前
查看次数:
28782 次
最近记录: