not all arguments converted during string formatting Python+mysql 写入数据库的的错误

>>> cur.execute("INSERT INTO foo VALUES (%s)", "bar")    # WRONG
>>> cur.execute("INSERT INTO foo VALUES (%s)", ("bar"))  # WRONG
>>> cur.execute("INSERT INTO foo VALUES (%s)", ("bar",)) # correct
>>> cur.execute("INSERT INTO foo VALUES (%s)", ["bar"])  # correct
--------------------- 
作者:IMrChang 
来源:CSDN 
原文:https://blog.csdn.net/chang1976272446/article/details/73498683?utm_source=copy 
 

你可能感兴趣的:(python)