-
Python Enumpython/기본 2022. 10. 21. 20:44
import enum @enum.unique class Status(enum.Enum): Active = 1 InActive = 2 class Permission(enum.IntFlag): R = 4 W = 2 X = 1 if __name__ == '__main__': print(Status.Active.value) # 1 print(Status(2)) # Status.InActive for s in Status: print(s) print(Permission.R | Permission.W) # Permission.R|W RW = Permission.R | Permission.W print(Permission.R in RW) # True print(Permission.X in RW) # False
'python > 기본' 카테고리의 다른 글
Match (0) 2024.01.31 Python Closure (0) 2022.10.21 requirements.txt 자동 생성하기 (0) 2022.05.31 datetime / time (0) 2022.05.02 tempfile / subprocess (0) 2022.05.02