enum模块的作用

    enum模块定义了一个提供迭代和比较功能的枚举类型。可以用这个模块为值创建明确定义符号,而不是使用字面量整数或字符串。

1、创建枚举

import enum


class BugStatus(enum.Enum):
    new = 7
    incomplete = 6
    invalid = 5
    wont_fix = 4
    in_progress = 3
    fix_committed = 2
    fix_released = 1


print('\nMember name: {}'.format(BugStatus.wont_fix.name))
print('Member value: {}'.format(BugStatus.wont_fix.value))
enum_create.py

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-06
  • 2021-06-25
  • 2021-10-06
  • 2021-06-09
  • 2021-12-14
  • 2022-12-23
相关资源
相似解决方案