python postgresql TypeError: not all arguments converted during string formatting
python postgresql TypeError: not all arguments converted during string formatting
命令“INSERT into route_list VALUES ('0.0.0.0/0')”没有问题。但是循环不起作用。这个错误是什么意思?以及如何摆脱她?
data = ['0.0.0.0/0']
for d in data:
cursor.execute("INSERT into route_list VALUES %s", d)
TypeError:在字符串格式化期间并非所有参数都已转换
使用这个:
cursor.execute("INSERT into route_list VALUES (%s)", [d])
or
cursor.execute("INSERT into route_list VALUES (%s)", (d,))
or
cursor.execute("INSERT into route_list VALUES ('{0}')".format(d))
命令“INSERT into route_list VALUES ('0.0.0.0/0')”没有问题。但是循环不起作用。这个错误是什么意思?以及如何摆脱她?
data = ['0.0.0.0/0']
for d in data:
cursor.execute("INSERT into route_list VALUES %s", d)
TypeError:在字符串格式化期间并非所有参数都已转换
使用这个:
cursor.execute("INSERT into route_list VALUES (%s)", [d])
or
cursor.execute("INSERT into route_list VALUES (%s)", (d,))
or
cursor.execute("INSERT into route_list VALUES ('{0}')".format(d))