python MySQLdb 去掉警告信息(Warning)

Here is a quick three line snippet that will suppress all of those annoying warning messages from MySQL when using MySQLdb:

from warnings import filterwarnings
import MySQLdb as Database
filterwarnings('ignore', category = Database.Warning)

To re-enable the warnings later on:

from warnings import resetwarnings
resetwarnings()

More about the warnings Python standard library:
http://docs.python.org/library/warnings.html 


http://www.zuoann.com

你可能感兴趣的:(python)