作者lucy35 ()
看板Python
標題[問題] 插入值到mysql
時間Mon Dec 2 01:22:09 2019
http://i.imgur.com/2yGxAf8.jpg
我要把資料丟進mysql
可是有錯誤
http://i.imgur.com/7RR7jLM.jpg
想請問要怎麼解決這個問題?
資料庫裡屬性數量是4
程式碼也是4
下面這個是b裡面的格式
http://i.imgur.com/I2hv9IQ.jpg
-----
Sent from JPTT on my OPPO CPH1701.
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 223.138.51.78 (臺灣)
※ 文章網址: https://webptt.com/m.aspx?n=bbs/Python/M.1575220933.A.B89.html
※ 編輯: lucy35 (223.138.51.78 臺灣), 12/02/2019 01:23:28
1F:推 hongyan: str = ("%s %s %s %s")%(a, b, c, d) 12/02 02:00
2F:→ hongyan: 不然就是 (".... vaules({},{},{},{})").format(a,b,c,d) 12/02 02:01
3F:→ hongyan: 更正1F(".... values (%s, %s, %s ,%s)")%(a, b , c ,d) 12/02 02:04
4F:推 ilms49898723: 我猜 cursor.execute(insert, b) 就好 12/02 11:55
會顯示
not all argument converted during string formatting 錯誤
※ 編輯: lucy35 (223.138.51.78 臺灣), 12/02/2019 20:41:13
5F:→ justoncetime: 找pastbin之類貼完整程式碼 12/02 22:10
6F:推 marc47: for row in b: 12/04 03:19
7F:→ marc47: cursor.execute(insert,row) 12/04 03:19
解決了!!謝謝
※ 編輯: lucy35 (42.76.105.109 臺灣), 12/09/2019 01:04:53