Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/353.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python ';datetime.date';如果在变量中赋值两次,则对象不可调用_Python_Selenium_Datetime_Url_Callable - Fatal编程技术网

Python ';datetime.date';如果在变量中赋值两次,则对象不可调用

Python ';datetime.date';如果在变量中赋值两次,则对象不可调用,python,selenium,datetime,url,callable,Python,Selenium,Datetime,Url,Callable,我有下面的代码,由于某种原因我不能有 lastMonthEnd.strftime(“%d”)、lastMonthEnd.strftime(“%b”)和lastMonthEnd.strftime(“%Y”)在一个变量内执行两次 我声明时间变量 today = date.today() first = today.replace(day=1) lastMonthEnd = first + dateutil.relativedelta.relativedelta(days=-1) lastQua

我有下面的代码,由于某种原因我不能有

lastMonthEnd.strftime(“%d”)、lastMonthEnd.strftime(“%b”)和lastMonthEnd.strftime(“%Y”)
在一个变量内执行两次

我声明时间变量


today = date.today()
first = today.replace(day=1)
lastMonthEnd = first +  dateutil.relativedelta.relativedelta(days=-1)

lastQuaterBegin = first + dateutil.relativedelta.relativedelta(months=-3)
lastMonthBegin = first + dateutil.relativedelta.relativedelta(months=-1)
我得到的第一个网址没有任何问题

# Get P&L monthly
    plUrl = "https://go.xero.com/Reports/Report2.aspx?"\
                "reportId=ca205001-1651-4947-bf95-9b1436926f09&report=&statement"\
                "=a22c12ce-7b22-49ff-a674-1a509552f6de&attPage=Compare%20Periods&"\
                "date="+lastMonthEnd.strftime("%d")+"%20"+lastMonthEnd.strftime("%b")+"%20"+lastMonthEnd.strftime("%Y")+\
                "&timeframe=1&periods=3&budgetID=%20&total=null&ytd=null&"\
                "&CompareDateRangePeriods=1&sortByForAccount=FormattedName&cashOnly=null"
               
    driver.get(plUrl)
但是,当我在URL中两次运行下面的代码,其中有
lastMonthEnd.strftime(“%d”)、lastMonthEnd.strftime(“%b”)和lastMonthEnd.strftime(“%Y”)
,我会得到一个

模块中文件“XXX”,第145行 “toDate=“+lastMonthEnd.strftime(“%d”)+“%20”+lastMonthEnd.strftime(“%b”)+“%20”+lastMonthEnd.strftime(“%Y”)+”和”\

TypeError:“datetime.date”对象不可调用

错误

plUrl = "https://go.xero.com/Reports/Report2.aspx?reportId=ca205001-1651-4947-bf95-9b1436926f09&report=&"\
                "statement=a22c12ce-7b22-49ff-a674-1a509552f6de&attPage=Show%20Date%20Range&"\
                "date="+lastMonthEnd.strftime("%d")+"%20"+lastMonthEnd.strftime("%b")+"%20"+lastMonthEnd.strftime("%Y")+"&"\
                "timeframe=1&periods=3&budgetID=%20&total=null&ytd=null&"\
                "fromDate="+lastQuaterBegin("%d")+"%20"+lastQuaterBegin("%b")+"%20"+lastQuaterBegin("%Y")+"&"\
                "toDate="+lastMonthEnd.strftime("%d")+"%20"+lastMonthEnd.strftime("%b")+"%20"+lastMonthEnd.strftime("%Y")+"&"\
                "CompareDateRangePeriod=none&CompareDateRangePeriods=1&sortByForAccount=FormattedName&cashOnly=null"
                            
    driver.get(plUrl)

有人能帮忙解决这个问题吗?

你好像忘了在一些
DateTime
对象上添加
.strftime

快乐编码,
Breadberry

您似乎忘记在一些
DateTime
对象上添加
.strftime

快乐编码,
Breadberry

您忘记了
strftime
,例如它应该是
lastQuaterBegin.strftime(“%d”)
,谢谢您的提示。我正在使用上述主题的解决方法。您忘记了
strftime
,例如,它应该是
lastQuaterBegin.strftime(“%d”)
,谢谢您的提示。我正在为上面的主题使用变通方法。谢谢你的提示。我正在为上面的主题使用变通方法。谢谢你的提示。我正在使用上述主题的变通方法。