1
在python中,我從數據庫獲取了fetchall數據。在Python中將fetch_all數組轉換爲單個數組
SENTENCE = "It is wonderful. I'am happy"
sent= (word_tokenize(SENTENCE))
cursor = conn.cursor()
format_strings = ','.join(['%s'] * len(sent))
cursor.execute("SELECT emotion_type FROM emotion WHERE key_word IN (%s)" % format_strings,tuple(sent))
results = cursor.fetchall()
for i in results:
z= (i)
輸出是
('happy',)
('happy',)
但我希望得到這個結果作爲
['happy','happy']
如果有任何可能的方式來獲得輸出,因爲我想。請幫幫我 !
謝謝。這正是我真正想要的。 – Chathurika