2024-09-29 19:24:43 发布
网友
我已经试了一段时间了,在网上查了一下,想不通。在
变量是numbers和{}
numbers
sql = ("INSERT INTO favourite (number, info) VALUES (numbers, animals )") cursor.execute(*sql) conn.comit()
sql = ("INSERT INTO favourite (number, info) VALUES (%s, %s)", (numbers, animals))
为了安全起见,请始终使用escape,请参见http://dev.mysql.com/doc/refman/5.7/en/string-literals.html
使用:
sql=("INSERT INTO favourite (number, info) VALUES ({},{})".format(numbers,animals))
根据将来的参考资料使用格式总是很好的。 检查https://docs.python.org/release/3.1.5/library/stdtypes.html#old-string-formatting-operations
我认为下面的方法应该行得通。让我知道你是怎么做的。在
sql = ("INSERT INTO favourite (number, info) VALUES ( %d, %s)") %(numbers, animals)
为了安全起见,请始终使用escape,请参见http://dev.mysql.com/doc/refman/5.7/en/string-literals.html
使用:
根据将来的参考资料使用格式总是很好的。 检查https://docs.python.org/release/3.1.5/library/stdtypes.html#old-string-formatting-operations
我认为下面的方法应该行得通。让我知道你是怎么做的。在
相关问题 更多 >
编程相关推荐