SQLite select查询返回python中前面带有u的字符串

时间:2015-03-12 14:27:11

标签: python sqlite

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

1 个答案:

答案 0 :(得分:3)

您正在打印整行,始终将成为元组。

如果您只想打印第一列,请使用订阅:

print(row[0])