파이썬에서 if문을 한줄에 사용하고 싶을 때,
expression_if_true if condition else expression_if_false
이렇게 하면 된다.
위와 같은 구문은 python이 2.5 버전 이상일 때, 가능하다.
'Computer > Python' 카테고리의 다른 글
| 한글의 자모 분리 (0) | 2015.12.03 |
|---|---|
| 파이썬 json.dumps를 한글에 사용하는 방법 (0) | 2015.02.01 |
| nested list comprehesion in python (0) | 2015.01.10 |
| python OrderedDict (0) | 2014.12.04 |
| 파이썬 표준 에러(stderr) 출력 (0) | 2014.11.21 |