根据the Python documentation,我可以传递多个警告过滤器:
When listing multiple filters on a single line (as for PYTHONWARNINGS), the individual filters are separated by commas
但是当我尝试这样做时,Python抱怨它忽略了无效的选项。在这里,我试图传递always::::
和error::RuntimeWarning::
:
$ python -W 'always::::,error::RuntimeWarning::' -c "print('hello, world')"
Invalid -W option ignored: too many fields (max 5): 'always::::,error::RuntimeWarning::'
如果我跑就行了
PYTHONWARNINGS="always::::,error::RuntimeWarning::" python -c "print('hello, world')"
但是把它作为命令行标志传递的语法是什么呢?你知道吗
尝试将以下内容添加到脚本中
相关问题 更多 >
编程相关推荐