如何忽略 Python 中的弃用警告

问题描述

warnings模块的文档:

 #!/usr/bin/env python -W ignore::DeprecationWarning

如果您在 Windows 上:-W ignore::DeprecationWarning作为参数传递给 Python。最好通过强制转换为int解决问题。

(请注意,在 Python 3.2 中,认情况下会忽略弃用警告。)

解决方法

我不断得到这个:

DeprecationWarning: integer argument expected,got float

如何让这条消息消失?有没有办法避免 Python 中的警告?