본문 바로가기

AI/Python

NoneType check

파이썬에서 NoneType 체크

 

is 연산자 활용

if variable is None:
	...
    
if variable is not None:
	...

 

변수 유형 체크

name = None # True --> name = 12
if type(name) != type(None):
    print(name)
else:
    print("Can't find name")
반응형