python 中使用map 构建sql查询语句

args=['A', 'C']
sql='SELECT fooid FROM foo WHERE bar IN (%s)' 
in_p=', '.join(list(map(lambda x: '%s', args)))
sql = sql % in_p
cursor.execute(sql, args)

 

posted on 2013-04-24 17:24  Harveyaot  阅读(326)  评论(0编辑  收藏  举报

导航