Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的代码 python 有问题,我使用的是 Pandasql,我想要的是在查询中使用我的 (enddate),所以:
enddate = pd.to_datetime(datetime.today()).date()
q2 = """SELECT * FROM res_q1 t1 where t1.JOURS = (enddate) """ res_q2 = psql.sqldf(q2, locals())
你能帮我吗?
您可以使用格式添加它,例如
from datetime import datetime end_date = pd.to_datetime(datetime.today()).date() q2 = """SELECT * FROM res_q1 t1 where t1.JOURS = ({}) """.format(end_date) res_q2 = psql.sqldf(q2, locals())
希望这可以帮助 :)