记一次python开发中遇到查询sql条件为in时,写法如下:
sql = "SELECT * FROM tb_attribute WHERE name in ({}) and is_delete = 0".format(
','.join(["'%s'" % item for item in names]))
#如果你取到的值是空的则需加上.strip():
sql = "SELECT * FROM tb_attribute WHERE name in ({}) and is_delete = 0".format(
','.join(["'%s'" % item.strip() for item in names]))