0
我有一個deque
最大長度爲10.是可能的.extendleft
並添加一個元組。例如:Python deque extendleft與元組?
from collections import deque
x = deque(maxlen = 10)
z = [(1,4),(1,3),(2,5),(7,1),(6,4),(8,2),(9,1),(9,5),(7,3),(8,3)]
for y in z:
x.append(y)
print x
x.extendleft((6,7))
print x
返回:
deque([(1, 4), (1, 3), (2, 5), (7, 1), (6, 4), (8, 2), (9, 1), (9, 5), (7, 3), (8, 3)], maxlen=10)
deque([7, 6, (1, 4), (1, 3), (2, 5), (7, 1), (6, 4), (8, 2), (9, 1), (9, 5)], maxlen=10)
我嘗試: 對=(6,7) x.extendleft(對) 具有相同的結果。