我定義我的代碼我的日期窗口這樣錯誤佔位符日期
import pandas as pd
#####
end = datetime.datetime.now()
end = end.date()
start = end - days * pd.tseries.offsets.BDay()
start = start.date()
並使用它像這樣
print('After analysing from %s to %s' %(datetime.date(start), datetime.date(end)))
print('Duration: %1.1f Years ~ %d workdays - Extent: %d strategies and %d tickers' '\n'
'The following matrix of tickers and strategies show highest potential:' %(years, days, len(strategies), len(stocklist))
)
但我得到一個錯誤
print('After analysing from %s to %s' %(datetime.date(start), datetime.date(end)))
TypeError: an integer is required (got type datetime.date)
有誰知道我如何正確使用日期?謝謝,我在這裏的搜索沒有返回任何我能理解的東西。
你能不能只用'%(起點,終點)'因爲這些已經是'datetime'對象了? – xnx