我正在尝试从sqlite表中获得干净的输出值,但到目前为止还不走运。输出值上带有,'和()。
>>> import sqlite3
>>> db = sqlite3.connect('C:\\Users\\userRock\\Desktop\\gen_profile.sqlite')
>>> cur = db.cursor()
>>> cur.execute (''' CREATE TABLE user (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT) ''')
<sqlite3.Cursor object at 0x002E0EE0>
>>> db.commit()
>>> cur.execute (''' INSERT INTO user(name) VALUES ('John'),('James') ''')
<sqlite3.Cursor object at 0x002E0EE0>
>>> db.commit()
>>> cur.execute (''' SELECT name FROM user ORDER BY RANDOM() LIMIT 1 ''')
<sqlite3.Cursor object at 0x002E0EE0>
>>> text = cur.fetchone()
>>> print (text)
('James',)
>>>
输出为('James,),但我想得到James,只是名字不带符号。我该怎么办?
非常感谢你
喵喔喔
相关分类