파이썬[Python]: collections - maps 변수

collections 모듈 - maps 변수(variable)


/// 설명

ChinMap에 형성되어 있는 매핑들의 리스트를 보여줍니다.(순서: first-searched to last-searched)

※ 형식
chainmap.maps

reference
https://docs.python.org/3/library/collections.html#module-collections

/// 예제

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import collections
 
test_cm = collections.ChainMap()
 
print(test_cm)  # ChainMap({})
print(test_cm.maps)  # [{}]
 
test_dict1 = {'a'1'b'2'c'3}
test_dict2 = {'d'4'b'5'e'6}
 
test_cm = collections.ChainMap(test_dict1, test_dict2)
 
print(test_cm)  # ChainMap({'a': 1, 'b': 2, 'c': 3}, {'d': 4, 'b': 5, 'e': 6})
print(test_cm.maps)  # [{'a': 1, 'b': 2, 'c': 3}, {'d': 4, 'b': 5, 'e': 6}]
 
# the iteration order is determined by scanning the mappings last to first.
print(list(test_cm))  # ['d', 'b', 'e', 'a', 'c']
 
cs

* 실행환경: Microsoft Windows 10 Homes
* 인터프리터: 파이썬(Python 3.9)


– 당신을 응원합니다. –

댓글

이 블로그의 인기 게시물

파이썬[Python]: 내장함수 - from_bytes 메서드

파이썬[Python]: 내장함수 - __len__ 메서드

파이썬[Python]: kivy - 한글 사용

파이썬[Python]: 내장함수 - bit_length 메서드

C 언어: sin 함수, cos 함수, tan 함수