我想使用此代码从sqlite数据库列读取所有温度值,但输出显示[(u'29',), (u'29',), (u'29',)],我只是将数值存储在数据库中.我希望输出[29, 29, 29]
import sqlite3
conn = sqlite3.connect("growll.db")
cursor = conn.cursor()
print "\nHere's a listing of all the records in the table:\n"
cursor.execute("select lchar from GrowLLDados")
print cursor.fetchall()
Run Code Online (Sandbox Code Playgroud)
试试这个:
import sqlite3
conn = sqlite3.connect("growll.db")
cursor = conn.cursor()
print "\nHere's a listing of all the records in the table:\n"
cursor.execute("select lchar from GrowLLDados")
print [int(record[0]) for record in cursor.fetchall()]
Run Code Online (Sandbox Code Playgroud)