-3
我想用python創建數據庫,然後插入數據並顯示它。 但是,輸出在每個字符串前添加u
。 我該怎麼做,我該如何刪除「u」? 以下是輸出顯示:如何在數據庫表顯示之前刪除「u和''」python
-----------------------------------------------
| Date | Time | Price |
-----------------------------------------------
(u'31/05/2013', u'11:10', u'$487')
(u'31/05/2013', u'11:11', u'$487')
(u'31/05/2013', u'11:13', u'$487')
(u'31/05/2013', u'11:19', u'$487')
我想要的輸出只顯示像
-----------------------------------------------
| Date | Time | Price |
-----------------------------------------------
31/05/2013 11:10 $487
我不希望看到的u
和''
。
以下是我的代碼的一部分
cursor.execute("CREATE TABLE if not exists table2 (date text, time text, price real)")
date=strftime("%d/%m/%Y")
time=strftime("%H:%M")
data1 = [(date,time,eachprice),
]
cursor.executemany('INSERT INTO table2 VALUES (?,?,?)', data1)
conn.commit()
#output
print "Showing history for 'ipad mini', from harveynorman"
print "-----------------------------------------------"
print "| Date | Time | Price |"
print "-----------------------------------------------"
for row in cursor.execute('select * from table2').fetchall():
print row
所以,會有人可以幫助我弄清楚如何刪除g
和''
@MartijinPieters感謝了很多,真正有幫助的,我刨閱讀的鏈接首先是因爲我仍然有很多表需要顯示。 –