fetchone与fetchmany对比

2024-09-28 17:18:40 发布

您现在位置:Python中文网/ 问答频道 /正文

for date in c.fetchone():
    [('date')]
    print date

上图:

^{pr2}$
for date in c.fetchmany(2):
    [('date')]
    print date

上图:

(u'02/27/2017',)  
(u'02/27/2017',)

不知道为什么它返回值u'xxx,),因为它现在将它打印为一个表?在

总之,我想把这两个值(行)保存在两个不同的变量中,以便最终与其他变量进行比较。在

for date in c.fetchmany(2):
    [('date')]
    print date
    for row in date:
        print row[0], row[1]

上述结果将导致:

(u'02/27/2017',)
0 2
(u'02/27/2017',)
0 2

但我希望它能打印:

(u'02/27/2017',)
02/27/2017
(u'02/27/2017',)
02/27/2017

for date in c.fetchmany(2):
    [('date')]
    print date
    for row in date:
        print row[0]

(u'02/27/2017',)
0
(u'02/27/2017',)
0

不知道怎么解决这个问题。谁能给我指出正确的方向吗?在

谢谢。在


Tags: infordate方向xxxrowprint返回值