如何抑制光标.执行()MySQLdb中的消息。在
>>> from warnings import filterwarnings
>>> import MySQLdb
>>> filterwarnings('ignore', category = MySQLdb.Warning)
>>> db = MySQLdb.connect('127.0.0.1', 'root', '','')
>>> cursor = db.cursor()
>>> cursor.execute("select version()")
1L
我需要抑制这个“1L”信息
您看到的不是警告消息,而是
cursor.execute()
的返回值。它是受影响的行数,1。在API碰巧返回一个Python ^{} integer ,但它与常规的
int
值相同:如果不希望Python控制台将返回值回送给您,请将它们分配给一个变量:
^{pr2}$相关问题 更多 >
编程相关推荐