0

抱歉,这可能真的很容易,但我是学习代码的新手,我正在尝试返回所有

yesterday = ((dt.date.today()-dt.timedelta(days=1)))    
cur.execute("SELECT * FROM iron_condor WHERE open='yes' AND DATE(buy_date)<DATE(?)"(yesterday))

我要拿回这个

Traceback (most recent call last):
  File "/home/pi/Documents/openoptions.py", line 86, in <module>
    cur.execute("SELECT * FROM iron_condor WHERE open='yes' AND DATE(buy_date)<DATE(?)"(yesterday))
TypeError: 'str' object is not callable
4

1 回答 1

0
yesterday = ((dt.date.today()-dt.timedelta(days=1)))    
cur.execute("SELECT * FROM iron_condor WHERE open='yes' AND DATE(buy_date)<DATE(?)", (yesterday,))

注意 2 个逗号。您可能需要转换yesterdaystr.

于 2020-12-29T10:21:20.067 回答