在sqlite python中使用变量时不打印的循环

在sqlite python中使用变量时不打印的循环,python,sqlite,Python,Sqlite,游标执行选择与变量“s”匹配,但 循环“for”使用“s”不起作用(不打印任何内容),但是,它与光标直接执行SELECT一起工作。有什么问题?“s”不是游标执行选择的同一对象吗 编程程序如下所示: >>>import sqlite3 >>>con=sqlite3.connect('prueba.db') >>>cur=con.cursor() >>>cur.execute('''CREATE TABLE tabla1(Ext

游标执行选择与变量“s”匹配,但 循环“for”使用“s”不起作用(不打印任何内容),但是,它与光标直接执行SELECT一起工作。有什么问题?“s”不是游标执行选择的同一对象吗

编程程序如下所示:

>>>import sqlite3
>>>con=sqlite3.connect('prueba.db')
>>>cur=con.cursor()
>>>cur.execute('''CREATE TABLE tabla1(ExtremoA text,ExtremoZ text,PotenciaRxA real,PotenciaTxA real,PotenciaRxZ real,PotenciaTxZ real,SpanLossAZ real,SpanLossZA real)''')
print "Tabla1 creada exitosamente"
>>>registros=[('Quillota','San felipe',-9,4,-11,3,15,12),('San Felipe','Las Cuevas',-10,2,-12,6,16,14)]
>>>sql='''INSERT INTO tabla1(ExtremoA,ExtremoZ,PotenciaRxA,PotenciaTxA,PotenciaRxZ,PotenciaTxZ,SpanLossAZ,SpanLossZA)VALUES(?,?,?,?,?,?,?,?)'''
>>>cur.executemany(sql,registros)
>>>con.commit()
>>>print "registros creados exitosamente"
>>>s=cur.execute('''SELECT * FROM tabla1''')   
>>>todo=cur.fetchall()
>>>print todo
>>>for i in s:
    print i
>>>cur.close()
>>>con.close()

todo=cur.fetchall()
中,您已经将行检索到
todo
中,因此没有任何内容可以重复。因此,循环执行
todo
,而不是
s
。。。否则,把那条线去掉,然后在
cur

我找到了!有些概念对我来说不是很清楚。没关系。