如何在python中传递变量的值

2024-09-30 20:18:35 发布

您现在位置:Python中文网/ 问答频道 /正文

我必须传递日期值作为变量。这是我计算当前mnth和prev的代码。mnth公司

import datetime
today = datetime.date.today()

Curr_Mnth=datetime.date(day=1,month=today.month,year=today.year)
Prev_Mnth=Curr_Mnth - datetime.timedelta(days=1)

c=str(Curr_Mnth.strftime("%Y%m%d"))
p=str (Curr_Mnth.strftime("%Y%m%d"))

我要传递c和p的值

ENDPOINT_site_totals = '/sites/site_totals?DateStamp=gte:"c":+AND+lt:"p"'

有人能帮我吗。你知道吗


Tags: 代码todaydatetimedatesite公司yearstr