我正在执行从 python 程序到 MySQL 5.2.39 数据库的选择查询。但是mysql编辑器选择查询和python程序选择查询的结果略有不同。数据库名是world,表名是wordcount,它有4列:id、author、word、count。为什么那些 L 后缀出现在 python 结果中?谁能说出可能是什么原因?即使我尝试将整个长选择查询表达式放在我的 python 代码中的单行中,但仍然是同样的问题。我正在使用 Eclipse 和 Pydev。下面是我的python代码:
import MySQLdb as mdb
import sys
con = mdb.connect('localhost', 'root', '1234', 'world')
con.autocommit(True)
with con:
cur = con.cursor()
cur.execute("select author,count(distinct word),count(distinct id) from \
world.wordcount \
group by author \
having count(distinct word)<> count(distinct id) \
order by author")
rows = cur.fetchall()
for row in rows:
print row
来自 python 的示例结果:
('A GONZ LEZ', 18L, 19L)
('A M MORENO', 8L, 9L)
MySQL 编辑器的示例结果:
A GONZ LEZ|18|19
A M MORENO| 8| 9