python - 集合双端队列构造函数

标签 python collections deque

你能解释一下双端队列的this构造函数吗:

import collections
buff = collections.deque([], 100)

我看到了它的文档,但找不到在任何地方使用此表单。

最佳答案

class collections.deque([iterable[, maxlen]])

Returns a new deque object initialized left-to-right (using append()) with data from iterable. If iterable is not specified, the new deque is empty.

在您的示例中,buff = collections.deque([], 100),

创建一个新的空双端队列对象 buff,由第一个参数指定,maxlen 为 100。这意味着双端队列对象的最大长度为 100。

这是link对于文档,它解释得很好而且很清楚。

关于python - 集合双端队列构造函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37803574/

相关文章:

c++ - 了解 C++ 中的以下数据类型

python - 替代 df.iterrows() 用于连接两个 Postgres 表和计算功能

java - Collection.Max 的打印输出

python - 使用pytest对学生代码进行测试和评分

Java - 在对象列表中搜索 2 个日期之间的日期

java - 比较列表中的元素,如果某些属性相同则移除

Java添加到队列的前面-deque

c++ - std::deque 或 std::list

python - 缩放复杂 numpy 数组的实部

python - 从 ipython 运行时按预期将包添加到 sys.path 导入的脚本,但从 python 运行脚本时抛出异常