鍍金池/ 問答/Python  數(shù)據(jù)庫/ python 操作Mysql %s怎么用

python 操作Mysql %s怎么用

圖片描述

cs1.execute('select id from score where id=%s',(flag,)) 這樣是正常輸出 1
上面這個怎么改成下面這個??
cs1.execute('select %s from score where id=%s',(p,flag)) 這樣是輸出 id

回答
編輯回答
陪她鬧
'select %s from score where id=%s' % (p,flag)
2017年7月14日 18:58