【Python】关闭 warning 信息提示

  • Post author:
  • Post category:python




背景




在使用 python MySQLdb 执行sql 命令的时候,如果执行结果含有warning,则会被写入到 stderr 展示到终端命令行。其实这些warning提示信息没有任何实际的作用。



root@rac3:~/scripts# >python set_ms.py -m 10.0.2.15:3306 -s 10.0.2.6:3308



Begin to set Replicate on slave 10.0.2.6:3308



set_ms.py:35: Warning: Slave already has been stopped



ret=cursor.execute(SQL)



set_ms.py:35: Warning: Sending passwords in plain text without SSL/TLS is extremely insecure.



ret=cursor.execute(SQL)



set_ms.py:35: Warning: Storing MySQL user nam