【问题标题】:How to pass the value of the variable in python如何在python中传递变量的值
【发布时间】:2015-08-31 19:22:09
【问题描述】:

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

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"'

谁能帮帮我。

【问题讨论】:

    标签: python date


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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-08-30
      • 2019-08-30
      • 1970-01-01
      • 2020-07-24
      • 2013-11-09
      • 2016-12-21
      • 1970-01-01
      相关资源
      最近更新 更多