-
방법1. Try Exception
try : thevariable exception NameError : print('was not defined') else : print('it is defined')
방법2. 전체 목록에서 찾기
if('var1' in locals()): print('it is defined1') if('var2' in globals()): print('it is defined2') if('var2' in vars()): print('it is defined3')
방법3. 멤버변수 확인
if('attr_name' in dir(classobj)): print('it is defined') if(hasattr(classobj,'attr_name')): print('it is defined')
'Python' 카테고리의 다른 글
Flask - 응답 전후처리 (0) 2020.07.13 Flask - Response (0) 2020.07.13 Flask - route (0) 2020.07.13 Flask예제 - User Login 검사와 결과 처리 (0) 2020.07.13 Python - Flask 설치 (0) 2020.07.13 Python - 플라스크(flask), 장고(django) (0) 2020.07.13 Vsc Python 준비 (0) 2020.07.03 Python - 클래스 멤버 변수 (1) 2020.06.21