打印 cursor.fetchall() 的结果,不带尾随 'L'

Printing results from cursor.fetchall() without the trailing 'L'

我有一个 python 代码,它通过 MySQLdb 访问 mysql 到 运行 一个 select 语句。然后我使用 cursor.fetchall() 将该输出收集为一个数组,但问题是它在每个输出的末尾打印一个 L,如下所示:

sql = "SELECT data1, data2  FROM table1, table2 ;"
cursor.execute(sql)
dataarray = cursor.fetchall()
print dataarray

>>> ((75379L, 45708L), ...)

但在我的 table 中,没有 L,只有数字。我怎样才能确保它只在没有 L 的情况下获取和打印数据?我宁愿避免在字符串上使用 [:-1],因为它会将我的 None 值更改为 Non.

L表示long整型。在 Python 2 中,它自动用于太大而无法表示为普通整数的值。

MySQLdb 似乎总是 return longs:

While MySQL's INTEGER column translates perfectly into a Python integer, UNSIGNED INTEGER could overflow, so these values are converted to Python long integers instead.

对这些值调用 str() 应该省略尾随 'L'