python:
task_group_id = ",".join(str(x) for x in task_group_id_list) 将list转化为(1,2,3) 可用于sql
java: list里是 str 的话 拼接的时候 把 ' ' 拼接上
StringBuilder port_id_lists =new StringBuilder();
for (int i=0; i
if (i==0){
port_id_lists.append("'").append(port_id_list[i]).append("'");
}else{
port_id_lists.append(",").append("'").append(port_id_list[i]).append("'");
}
}
"select * from table1 where id in (%s)" % (task_group_id)
网友评论