我正在寻找将从 mysql 返回的行中搜索最大时间值的脚本。Mysql返回的行如下:
(123, 'new', datetime.datetime(2013, 1, 2, 16, 6, 21))
(122, 'old', datetime.datetime(2012, 12, 3, 18, 08, 36))
(125, 'new', datetime.datetime(2012, 12, 13, 20, 18, 16))
我试过:
value = 0
for row in rows:
if row[2] > value:
value = row
print value
如果我们打印将显示的 row[2] 值
for row in rows:
print row[2]
output: 2013-01-02 16:06:21
2012-12-03 18:08:36
2013-12-13 20:18:16