python sql中含参数

python查询数据库,需要传参。

in_name是一个变量或参数。

sql='select id from customers where name=这里要写in_name'

应该用什么格式?


sql='select id from customers where name={}'.format(in_name)

str字符串,比如 'lisi'

可以用format函数