如何不显示消息“ DEPRECATION:Python 2.7将于2020年1月1日到期”?

时间:2019-07-31 13:56:44

标签: python-2.7 deprecated

我一直在查询软件包的新版本。在每个查询中,我都会在命令提示符下获得python 2.7弃用消息。我有办法藏起来吗?

完整的消息是:

DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support

1 个答案:

答案 0 :(得分:2)

您可以在脚本中使用休闲代码,

import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)

Reference