简体   繁体   中英

How to pass the value of the variable in python

I have to the pass the date value as the variable. here is my code to calcuate current mnth and 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"))

I want the the value fo the c and p to be passed

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

Can anyone help me in this .

ENDPOINT_site_totals = '/sites/site_totals?DateStamp=gte:"{0}":+AND+lt:"{1}"'.format(c, p)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM