프로젝트 로그/테스트x솔루션 JIG 개발기
[Python] 정수형 Class 변수 선언 방법
Life4IoT.rnd
2022. 6. 1. 20:11
반응형
아래와 같이 클래스의 변수를 선언 하면, 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 'tuple'>
이를 정수형태로 변환 하기 위해서는 아래와 같이 선언 하면 된다.
class testResult(enum.IntEnum):
TEST_SUCCESS = 0,
TEST_FAIL = 4
print("TEST type : {0}".format( type(testResult.TEST_SUCCESS)) )
>> TEST type : <enum 'testResult'>
반응형