设置模块弃用警告
回答
停止使用sets
模块,或切换到不推荐使用的较旧版本的python。
根据pep-004,sets
已从v2.6弃用,取而代之的是内置的set
and frozenset
types。
+1:通过修复导致警告的问题修复警告。看起来很简单。 – 2010-01-11 11:15:13
它只是看起来很简单,如果你知道有一个内置的替换它。为什么警告不这么说? – GreenAsJade 2016-01-08 11:10:59
您不需要导入sets
模块以使用它们,它们位于内置命名空间中。
历史:
的Python 2.3之前:没有设定功能
的Python 2.3:sets
模块赶到
的Python 2.4:set
和frozenset
内置插件推出
的Python 2.6:sets
模块弃用
您应该更改您的代码以使用set
而不是sets.Set
。
如果您仍然希望能够使用Python 2.3的支持,你可以在你的脚本开始这样做:
try:
set
except NameError:
from sets import Set as set
如果你要修复它詹姆斯绝对有正确的答案,但在如果你只想关闭废弃警告,你可以像这样运行python:
$ python -Wignore::DeprecationWarning
Python 2.6.2 (r262:71600, Sep 20 2009, 20:47:22)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sets
>>>
(来源:http://puzzling.org/logs/thoughts/2009/May/3/python26-deprecation-warning)
您也可以忽略它编程:
import warnings
warnings.simplefilter("ignore", DeprecationWarning)
- 1. django弃用警告位置
- 2. 弃用警告
- 3. 弃用警告
- 4. 弃用警告
- 5. nosetest弃用警告
- 6. 弃用警告Python
- 7. CRT弃用警告
- 8. Astropy弃用警告
- 9. 弃用警告:seed`
- 10. Scalatest弃用警告
- 11. Em.View.create弃用警告
- 12. 弃用警告4
- 13. 例弃用警告
- 14. Moment.JS弃用警告
- 15. BindingAdapter弃用警告
- 16. Rspec:弃用警告
- 17. Mpdboot:弃用警告
- 18. ActiveSupport中的InstanceMethods模块::关注..弃用警告
- 19. 摆脱Hbase配置弃用警告
- 20. Verilog模块警告
- 21. Python:从当前已弃用的位置导入模块时发出警告
- 22. xcode7禁用弃用警告
- 23. Django 1.9弃用警告app_label
- 24. Rails已弃用的警告
- 25. 水豚的弃用警告
- 26. WriteToFile:自动弃用警告
- 27. 角时刻弃用警告
- 28. MOJO perl已弃用警告
- 29. 弃用警告在Django
- 30. py2neo Graph.find_one()弃用警告?
哪个版本的Python? – 2010-01-11 08:27:37
Python版本2.6.4 – Dave 2010-01-11 08:28:15