python sqlite3如何模糊查詢變量?
剛學的,代碼在python 3.2.3下。不知道妳的版本是什麽,大家參考壹下就好。以下代碼改編自python手冊中的示例。import SQLite 3 con = SQLite 3 . connect(":memory:")cur = con . cursor()cur . execute(" create table people(name,age)")who = "Yeltsin"age = 72#這是qmark樣式:cur . execute(" insert into people values(?, ?)",(who,age))#查詢使用like子句execute(" select * from people where name like?",(' %Yel% ',)).