【发布时间】:2012-12-28 04:04:40
【问题描述】:
我是 Python 的新手,正在涉足该语言的各种特性。我发现的一个特点是以下代码 sn-p 的输出:
qry = 'SELECT COUNT(*) FROM <<TABLE>>'
cursor.execute(qry)
rowCounts = cursor.fetchone()
print("The number of rows in the <<TABLE>> table : {}".format(rowCounts))
我在终端上得到以下输出:
Connected to the MySQL database.
The number of rows in the <<TABLE>> table : (150L,)
我被括号和逗号难住了。我已经搜索了解释这种情况的答案,但没有找到任何合理的格式解释。有什么我应该做的不同的事情吗?
感谢所有帮助。
【问题讨论】:
-
什么数据库/ORM(即 SQLAlchemy)?
type(rowCounts)和type(rowCounts[0])的输出是什么?我怀疑这是一个包含 Long 的元组
标签: python database number-formatting