尝试学习 python 并建立 mysql 连接,我希望下面的代码使用 fetchone 在下面的代码中返回 None 但它正在返回一个对象,有人可以帮助理解这种行为。
import mysql.connector as m
con=m.connect(host='localhost',
user='root',
password='mysql',
database='reva')
cs3=con.cursor()
q='select * from toy where tid="10111"'
print(q)
cs3.execute(q)
row=cs3.fetchone
print(row)
while row is not None:
print(row)
row = cs3.fetchone()
cs3.close
con.close
输出是这个
select * from toy where tid="10111"
<bound method MySQLCursor.fetchone of <mysql.connector.cursor.MySQLCursor object at 0x10d29b550>>
<bound method MySQLCursor.fetchone of <mysql.connector.cursor.MySQLCursor object at 0x10d29b550>>