python
[python3] 파이썬 값/타입 확인 예제
'김용환'
2017. 9. 28. 18:04
파이썬에서 타입, 값을 확인할 수 있는 예제이다.
type()을 이용해 타입 확인할 수 있다.
print("aaaaaaa : " + str(type(result)))
str()을 이용해 값을 확인할 수 있다.
print("aaaaaaa : " + str(result))
string 인스턴스라면..
if isinstance(result, str):
string 인스턴스가 아니라면.
if not isinstance(result, str):
None을 확인하는 코드이다.
a = None
if not a:
print("1")
else:
print("2")
결과는 다음과 같다.
1
None을 체크하는 코드이다.
a = "1"
if not a:
print("1")
else:
print("2")
결과는 다음과 같다.
2