반응형
언팩킹이란? 요소를 여러 변수에 나누어 담는 것
locals()? 현재 scope 에 있는 local 변수를 딕셔너리 type( {key:value}
) 으로 반환
>>> nums = [1,2,3,4]
# unpacking
>>> a,*b = nums
>>> a
1
>>> b
[2,3,4]
>>> f'{a} {b} {nums}'
1 [2,3,4] [1,2,3,4]
# unpacking
>>> '{a} {b} {nums}'.format(**locals())
1 [2,3,4] [1,2,3,4]
728x90
728x90
BIG
'Programming > Python' 카테고리의 다른 글
list[::], tuple[::] - extended slices (0) | 2020.09.02 |
---|---|
index(), find() - 원소의 인덱스 (0) | 2020.09.01 |
copy - shallow, deep : 깊은복사, 얕은복사 (0) | 2020.08.19 |
generator - 제너레이터 (0) | 2020.08.18 |
숫자 출력 시 width에 맞춰서 앞에 0 채우기 (0) | 2020.07.28 |
댓글