반응형
- 코드 예시
import enum
class DaysOfWeek(enum.Enum):
MONDAY = 1
TUESDAY = 2
WEDNESDAY = 3
THURSDAY = 4
FRIDAY = 5
SATURDAY = 6
SUNDAY = 7
print(DaysOfWeek.MONDAY) # 출력: DaysOfWeek.MONDAY
print(DaysOfWeek(1)) # 출력: DaysOfWeek. 월요일
# 열거형 값 반복
for day in DaysOfWeek:
print(day)
# 출력:
# DaysOfWeek.MONDAY
# DaysOfWeek.TUESDAY
# DaysOfWeek.WEDNESDAY
# DaysOfWeek.THURSDAY
# DaysOfWeek.FRIDAY
# DaysOfWeek.SATURDAY
# DaysOfWeek.SUNDAY
반응형