出现module 'queue' has no attribute 'Queue'问题的解决

这篇文章主要介绍了出现module 'queue' has no attribute 'Queue'问题的解决方案,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教

module 'queue' has no attribute 'Queue'

import queue q = queue.Queue() q.put('a') q.put('b') print(q.get()) 错误: AttributeError: module 'queue' has no attribute 'Queue'

解决方法 

把程序名命名和包名一样导致错误。命名为queue1.py就ok了 

python:AttributeError: module 'xxx' has no attribute 'xxx'的错误

运行python程序时,也许会出现这样的错误:

AttributeError: module ‘xxx’ has no attribute ‘xxx’

如:

在我的学习中,解决该错误有两种方法

1.手动安装该模块

2.检查文件名

这个方式看起来很傻,但是却是新手经常会犯的错,原因是因为自己的文件名称和要使用的模块重名了:

只需要更改文件名即可

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持0133技术站。

以上就是出现module 'queue' has no attribute 'Queue'问题的解决的详细内容,更多请关注0133技术站其它相关文章!

赞(0) 打赏
未经允许不得转载:0133技术站首页 » python