84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
记录下,防止以后忘掉
原因是在mysql 中, 字段 in 后边应该加元祖(),而现在代码中传进去的参数是个列表,造成语法错误改正:
将要传递的参数使用 join()生成一个字符串传进去,另外,在MySQL语句中,dtu_id in (%s)(格式符放进元祖括号中)
新手上路,欢迎老司机指导纠正
小伙看你根骨奇佳,潜力无限,来学PHP伐。
Personal writing method for reference
db = MySQLdb.connect(*****) cursor = db.cursor() sql = "update test set name = 'test' where id in(%s)" args = [1, 2, 3] in_p = ', '.join((map(lambda x: '%s', args))) cursor.execute(sql % in_p, args) db.commit()
Personal writing method for reference