Python: Suppressing errors from going to commandline?

前端 未结 4 1077
粉色の甜心
粉色の甜心 2021-01-05 16:17

When I try to execute a python program from command line, it gives the following error. These errors do not cause any problem to my ouput. I dont want it to be displayed in

4条回答
  •  执笔经年
    2021-01-05 17:15

    In python 3, @Boaz Yaniv's answer can be simplified as

    sys.stderr = object
    

    since every class in python3 is inherited from Object, so technically this would work, at least I've tried it by myself in python 3.6.5 environment.

提交回复
热议问题