小编El_*_*ado的帖子

在 Python 中使用枚举和简单类变量调用有什么区别?

当我学习 Python 中的概念时,我遇到了这个枚举模块。我尝试了下面的代码:

import enum


# Using enum class create enumerations
class Days(enum.Enum):
   Sun = 1
   Mon = "raj"
   Tue = 3
   Wed= 123
   Thur=12312312
   Fri=1312312
   Sat=12122135435

   
# print the enum member as a string
print("The enum member as a string is : ",end="")
print(Days.Mon)

# print the enum member as a repr
print("he enum member as a repr is : ",end="")
print(repr(Days.Sun))
print(repr(Days.fri))

# Check type of enum member
print("The type of enum member is : ",end ="")
print(type(Days.Mon)) …
Run Code Online (Sandbox Code Playgroud)

python enums python-3.x

7
推荐指数
2
解决办法
3499
查看次数

标签 统计

enums ×1

python ×1

python-3.x ×1