언어/파이썬 & 장고

[Python] 삼항연산자

불곰1 2016. 8. 31. 10:51


(조건이 맞을 떄의 값) if 조건문 else (else일 떄 값)
 
# 예제
temp = 1 if 'apple' == 'apple' else '2'  # temp =1