我正在編寫腳本來查詢本週內包含特定網址的文章。我無法插入的網址,試圖使用LIKE過濾器來檢查某個網址。我嘗試插入,因爲我做了公開的開始和結束周,但它似乎與雙重插值混淆。你如何執行mysql包含與python中的網址?
澄清,該腳本在查詢
start_week = today - datetime.timedelta(today.weekday())
end_week = start_week + datetime.timedelta(7)
cursor = db.cursor(MySQLdb.cursors.DictCursor)
cursor.execute("""SELECT * FROM table WHERE url LIKE '%{http://foo.com/bar}%'""", [start_week, end_week])
result = cursor.fetchall()
print len(result)
感謝兄弟工作! – Dap