///
Search

deque ์“ธ ๋•Œ ์กฐ์‹ฌ

๋ถ„๋ฅ˜
์ž๋ฃŒ๊ตฌ์กฐ
์†์„ฑ
์ƒ์„ฑ์ผ
2022/02/04 19:05
์ตœ์ข… ์ˆ˜์ •
2022/02/04 19:08
deque ์„ ๋งŒ๋“ค๋•Œ iterator ๋ฅผ ์ธ์ž๋กœ ์ค˜์•ผํ•œ๋‹ค.
์ฆ‰, ์ˆซ์ž๋งŒ์„ ์ฃผ๋ฉด ์•ˆ ๋œ๋‹ค.
from collections import deque # ์ˆซ์ž๋งŒ ์ฃผ๋ฉด ์•ˆ ๋จ print(deque(1, 2)) # TypeError: 'int' object is not iterable # ๋ฆฌ์ŠคํŠธ ๊ฐ™์€๊ฑธ๋กœ ๋žฉํ•‘์„ ํ•ด์ค˜์„œ iterator ๋ฅผ ์ค˜์•ผํ•จ. print(deque([1])) # deque([1]) # ๋นˆ deq์„ ๋งŒ๋“ค๊ณ  append ๋ฅผ ํ•ด์ค˜๋„ ๋œ๋‹ค. deq = deque() deq.append(2) print(deq) # deque([2])
Python
๋ณต์‚ฌ