在Python/SQLite 3中格式化SQL查询输出

在Python/SQLite 3中格式化SQL查询输出,python,sql,sqlite,Python,Sql,Sqlite,我使用Python中的一个简单SQL查询从SQLite 3数据库中获取记录: cursor.execute ("SELECT due, task FROM tasks WHERE due <> '' ORDER BY due ASC") rows = cursor.fetchall() for row in rows: print '\n%s %s' % (row[0], row[1]) cursor.exec

我使用Python中的一个简单SQL查询从SQLite 3数据库中获取记录:

cursor.execute ("SELECT due, task FROM tasks WHERE due <> '' ORDER BY due ASC")
        rows = cursor.fetchall()
            for row in rows:
                print '\n%s %s' % (row[0], row[1])
cursor.execute(“选择到期,从到期的任务中选择任务”“按到期ASC排序”)
rows=cursor.fetchall()
对于行中的行:
打印“\n%s%s%”(第[0]行,第[1]行)
数据库中的到期字段设置为日期类型,因此查询返回此字段中格式为2010-07-20 00:00:00.00的数据。如何删除00:00:00.00,以便结果仅包含日期?谢谢

我认为第[0]行是一个对象。因此,以下措施应该有效:

print '\n%s %s' % (row[0].strftime('%Y-%m-%d'), row[1])

工作起来很有魅力。:-)谢谢您还可以编写查询,如
selectstrftime(“%Y-%m-%d',due),…