Python xlrd: suppress warning messages

前端 未结 5 1765
暖寄归人
暖寄归人 2021-01-02 10:19

I am using xlrd to process Excel files. I am running a script on a folder that contains many files, and I am printing messages related to the files. However, fo

5条回答
  •  清酒与你
    2021-01-02 10:48

    import warnings
    
    def fxn():
        warnings.warn("deprecated", DeprecationWarning)
    
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        fxn()
    

    -> http://docs.python.org/library/warnings.html#temporarily-suppressing-warnings

提交回复
热议问题