Suppress stdout / stderr print from Python functions

前端 未结 9 1898
情歌与酒
情歌与酒 2020-11-29 06:59

I have a Python script that is using some closed-box Python functions (i.e. I can\'t edit these functions) provided by my employer. When I call these functions, they are pri

9条回答
  •  生来不讨喜
    2020-11-29 07:45

    Just use Linux/Unix:

    ./myscript.py 2>/dev/null # gets rid of stderr
    ./myscript.py 2>/somewhere/myerror.log
    

提交回复
热议问题