小编Nir*_*mal的帖子

在python中导入类时显示警告

我在不同的模块中有一个类,我想在DeprecationWarning导入该类时显示一个。这样做的正确方法是什么?

模块 1 包含 -

class Test:
    pass
Run Code Online (Sandbox Code Playgroud)

模块 2 包含 -

from module1 import Test #this line should show a DeprecationWarning.
Run Code Online (Sandbox Code Playgroud)

python warnings exception deprecation-warning

6
推荐指数
1
解决办法
1051
查看次数

标签 统计

deprecation-warning ×1

exception ×1

python ×1

warnings ×1