第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Python MyQLdb執(zhí)行將不接受參數(shù)

Python MyQLdb執(zhí)行將不接受參數(shù)

湖上湖 2021-04-05 12:13:10
我發(fā)現(xiàn)了幾個類似的問題,但似乎都無法解釋這里發(fā)生的情況。代碼:print type(price)print type(sale_price)print type(url)price=0.0sale_price=0.0url="asdf"dbc.execute("UPDATE logTable SET price=%f, salePrice=%f, modified=NOW() WHERE url=%s", [price, sale_price, url])輸出:<type 'float'><type 'float'><type 'str'>Traceback (most recent call last):  File "./scrape.py", line 102, in <module>    dbc.execute("UPDATE logTable SET price=%f, salePrice=%f, modified=NOW() WHERE url=%s", [price, sale_price, url])  File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 210, in execute    query = query % argsTypeError: float argument required, not str插值字符串中沒有雜散的%字符。參數(shù)的數(shù)量與占位符的數(shù)量匹配。類型肯定是正確的。我嘗試使用?占位符,而不是printf樣式的占位符,即使文檔建議兩者都受支持。那給出了一個不同的例外:Traceback (most recent call last):  File "./scrape.py", line 102, in <module>    dbc.execute("UPDATE logTable SET price=?, salePrice=?, modified=NOW() WHERE url=?", [price, sale_price, url])  File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 210, in execute    query = query % argsTypeError: not all arguments converted during string formatting該異常還會產(chǎn)生大量的StackOverflow答案,但沒有一個真正揭示了這里出了什么問題。我確實嘗試使用元組而不是列表作為第二個參數(shù)來使用兩個樣式占位符執(zhí)行,但仍然會得到相同的異常。
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 156 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號