argument1 [문법] 가변인자 - *args, **kwargs Python에서 함수를 사용하다보면 매개변수를 가변적으로 전달하여 처리할 때가 있다. 가장 대표적인 예가 옵션을 설정할 때이다. Positional Argument로 floor를 받고, Keyword Argument로 tv, bed, computer를 받는 예제 함수를 통해 알아보자. 1 2 3 4 5 6 7 8 9 10 11 12 def dochiHouse(floor, tv=None, bed=None, computer=None): house = f'아파트 {floor}층' if floor is not None else '단독주택' things = 0 if tv is not None: things += tv if bed is not None: things += bed if computer is not N.. 2019. 12. 20. 이전 1 다음