How to suppress a third-party warning using warnings.filterwarnings

前端 未结 4 2038
忘了有多久
忘了有多久 2021-02-05 00:55

I am using Paramiko in my python code (for sftp). Everything works fine except that everytime I import or call a paramiko function. This warning would show up:

C         


        
4条回答
  •  执念已碎
    2021-02-05 01:03

    To filter only a specific warning:

    with warnings.catch_warnings():
        warnings.simplefilter('ignore', SpecificWarningObject)
    
        #do something that raises a Warning
    

提交回复
热议问题