我从数据库查询结果中得到元组,我想为每次迭代返回10行,你能帮忙python代码吗?
数据元组包含许多列表,我想返回10行,然后再返回10行,直到元组列表结束。
cur.execute (cmd,req_id = req_id)
data = cur.fetchall()
if cur.rowcount == 0: return 'Request details does not exist'
for row in data:
rstr += (""" <tr><td>%s</td> <td>%s</td><td>%s</td><td>%s</td><td>%s</td><td align="right" > <font color="blue"> %s </font></td><td align="right" ><font color="blue"> %s </font></td><td align="right"><font color="blue"> %s </font></td> </tr> """) % (str(row[0]), str(row[1]),str(row[2]),str(row[3]),str(row[4]),"{:,}".format(row[5]),"{:,}".format(row[6]),"{:,}".format(row[7]))
return rstr + "</table></body>"