在Python軟件語言中,str變體在添加到MySQL數據庫時會出錯。對我來說,這是這個角色的問題。你能幫忙嗎?Python MySQL數據庫,數據更新錯誤?
我寫的代碼行在底部。
rezerve='Aşkım Nasılsın?'
new_status = telStatus + 1
try:
tablo_birak = "UPDATE denemetablodd SET status='%s', rezerve='%s' WHERE ıd=1" % (str(new_status), str(rezerve))
imlec.execute(tablo_birak)
mysqlBaglanti.commit()
except:
mysqlBaglanti.rollback()
你能在你的問題上發佈python輸出的確切錯誤嗎? – JoshKopen
您應該使用準備好的語句,而不是替換爲字符串。 – Barmar
@JoshKopen, 這是我得到的錯誤。 UnicodeDecodeError:'ascii'編解碼器無法解碼位置0中的字節0xc3:序號不在範圍內(128) –