python tips:warning消除
两种方法:
1.在代码中
import warnings
warnings.filterwarnings("ignore")
2.运行时
python -W ignore script.py
ELSE:
以上两种方法对于库源码中的报错没有作用,比如对于torchtext中的warning.warn,目前是直接注释了源码中的warning.
/home/***/anaconda3/envs/py36/lib/python3.6/site-packages/torchtext/data/field.py:68: UserWarning: Field class will be retired soon and moved to torchtext.legacy. Please see the most recent release notes for further information.warnings.warn('{} class will be retired soon and moved to torchtext.legacy. Please see the most recent release notes for further information.'.format(self.__class__.__name__), UserWarning)
def fromJSON(cls, data, fields):#warnings.warn('Example class will be retired soon and moved to torchtext.legacy. Please see the most recent release notes for further information.', UserWarning)```
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
