-
[Python] ==(같다) 와 is (같다) 차이Python/Python Programming 2018. 5. 15. 01:13
구분
설명
예시
==
(부정 : !=)
값자체를 비교
a = 10
b = 10.0
if a == b:
print(True)
else:print(False)
True
is
(부정 : is not)
객체를 비교
a = 10
b = 10.0
if a is b:
print(True)
else:
print(False)
False
* a와 b의 객체가 다르기 때문에 False
a = 10
b = 10.0
print(id(a))
print(id(b))1347429360 804074922656
'Python > Python Programming' 카테고리의 다른 글
[Python] 3.6+에서 사전자료형(Dict)은 입력순서를 보존 (0) 2018.05.19 [Python] strip, rstrip, lstrip - 공백과 문자 제거 함수 (0) 2018.05.19 [Python] Gmail 보내기 (0) 2018.05.18 [Python] 단축평가(short-circuit evalution) (0) 2018.05.15 [Python] PEP - 스타일코드 공백(Whitespace) (0) 2018.05.14 [Python] 문자열 100개씩 잘라서 출력하기 (0) 2018.05.14 [Python] 반복가능 (iterable)한 객체 오른쪽(right) 순회 (0) 2018.05.13 [Python] 리스트에서 숫자요소의 인덱스 위치 구하기 (0) 2018.05.13