当前位置: 首页 > 图灵资讯 > 行业资讯> Python里SimpleQueue和LifoQueue的用法

Python里SimpleQueue和LifoQueue的用法

发布时间:2024-10-09 17:43:10

在python中类的实例方法使用,其中要给大家讲述的是SimpleQueue以及LifoQueue的使用,一个作用是无参数,并且长度,另一个基本上是和queue实例化是一样的,这边就给大家介绍这两个类的使用,除此以外,还有2个常见的类,大家可以带着了解下。

先进先出

代码演示:

fromqueueimportSimpleQueue
que=SimpleQueue()
que.empty()
que.qsize()
que.put(1)

先进后出

代码演示:

fromqueueimportLifoQueue
que=LifoQueue()

上述就是全部内容的介绍了。插播一个小贴士SimpleQueue 没有高级方法 join() 和 task_done(),这点大家也可以注意下,好啦,多看几遍,搞懂学会吧。

(推荐操作系统:windows7系统、Python 3.9.1,DELL G3电脑。)

相关文章

python3兼容python2吗

python3兼容python2吗

2025-05-09
python3 whl怎么安装

python3 whl怎么安装

2025-05-09
python 字典怎么提取value

python 字典怎么提取value

2025-05-09
python 怎样计算字符串的长度

python 怎样计算字符串的长度

2025-05-09
python 怎么样反向输出字符串

python 怎么样反向输出字符串

2025-05-09
python 怎么判断字符串开头

python 怎么判断字符串开头

2025-05-09