[Python] 정수형 Class 변수 선언 방법
아래와 같이 클래스의 변수를 선언 하면, Python에서는 testResult.TEST_SUCCSS 호출 시 [0]과 같은 tuple 형태로 표시 된다. class testResult(): TEST_SUCCESS = 0, TEST_FAIL = 4 print("TEST type : {0}".format( type(testResult.TEST_SUCCESS)) ) >> TEST type : 이를 정수형태로 변환 하기 위해서는 아래와 같이 선언 하면 된다. class testResult(enum.IntEnum): TEST_SUCCESS = 0, TEST_FAIL = 4 print("TEST type : {0}".format( type(testResult.TEST_SUCCESS)) ) >> TEST type :
2022.06.01