双端队列到 Python3 中的字符串

Deque to string in Python3

在 Python2 中,我能够做类似的事情:

frames = deque(maxlen=xyz)
framesString = ''.join(frames)

在 Python3 中出现错误。

我应该如何更改它以获得表示双端队列对象的字符串?

提前致谢, G.

来自Python官方documentation,你可以这样使用deque

from collections import deque

# With an infinite length
frames = deque('ytreza')
''.join(frames)
# It will display 'azerty'

# With a maximum length
frames = deque('ytreza', maxlen=3)
''.join(frames)
# It will display 'aze'

# With no input
assert len(deque(maxlen=3)) == 0
''.join(deque(maxlen(3)))
# It will display an empty string    

如果deque的内容是bytes,需要进行str转换,例如表达式生成器。

''.join(str(element) for element in my_deque)