我有一个由 4 个具有设定长度的双端队列组成的列表。我已经制作了该列表,希望它会像其他列表一样更新。这是一个简单的例子:
class foo():
def __init__(self):
self.buffer_size = 300
self.a = collections.deque([0]*self.buffer_size, self.buffer_size
self.b = collections.deque([0]*self.buffer_size, self.buffer_size
self.c = collections.deque([0]*self.buffer_size, self.buffer_size
self.d = collections.deque([0]*self.buffer_size, self.buffer_size
self.buffers = [list(self.a), list(self.b), list(self.c), list(self.d)]
def do_something(self):
## here I append to these deques so that the values in them changes
for i in range(20):
self.a.append(i)
self.b.append(i)
def _buffers(self):
## buffers will still be all zeros
print(self.buffers)
F = foo()
F.do_something()
F._buffers()
我的问题是为什么它仍然只是零?当其中的双端队列更改时,它为什么不更新?关于如何实现这一点的想法?