0
커서 실행 SELECT가 변수 "s"와 일치하지만 "for"루프는 "s"를 사용하여 작동하지 않습니다 (아무 것도 인쇄되지 않습니다). 그러나 , 커서와 함께 작동하여 SELECT를 직접 실행합니다. 문제가 무엇입니까? "s"가 커서와 같은 객체가 SELECT를 실행하지 않습니까?sqlite 파이썬에서 변수를 사용할 때 루프가 인쇄되지 않습니다
>>>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()
을 얻으십시오. 일부 개념은 분명하지 않습니다. 그게 다 괜찮아. –