作者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/cn.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