import sqlite3
#connect to the sqlite database
conn = sqlite3.connect('database.db')
#create a cursor
c = conn.cursor()
#select query to return a single row
c.execute('SELECT NAME FROM T1')
#row contains the returned result
row = c.fetchone()
#print the result
print(row)
它打印的内容类似于> (u'John',)
,但我只想要John
答案 0 :(得分:3)
您正在打印整行,始终将成为元组。
如果您只想打印第一列,请使用订阅:
print(row[0])