Using the ‘value’ property, you can get the enum member value.
enumMemberValue.py
from enum import Enum
class Day(Enum):
MONDAY = 1
TUESDAY = 2
WEDNESDAY = 3
THURSDAY = 4
FRIDAY = 5
SATURDAY = 6
SUNDAY = 7
for day in Day:
print(day.name, '->', day.value)
Output
MONDAY -> 1 TUESDAY -> 2 WEDNESDAY -> 3 THURSDAY -> 4 FRIDAY -> 5 SATURDAY -> 6 SUNDAY -> 7
No comments:
Post a Comment