Python에서 두 날짜를 비교하려고합니다.두 날짜를 비교할 때 오류가 발생했습니다.
AttributeError: 'datetime.date' object has no attribute 'date'
사람이 말할 수 : 나는 유형() 검사를 실행할 때 나는 두 날짜에 대한 간단한 검사를 실행할 때, 모두 내가 다음과 같은 오류를 얻을 <type 'datetime.date'>
그럼에도로 표시 내가 여기서 잘못하고있는 것. 아래 코드 :
d_today = date.today()
oldestDate = d_today - BDay(750)
avgArray2 = [x for x in avgArray if x[0] >= oldestDate.date()]
print type(oldestDate.date())
print type(avgArray[0][0])
그리고 출력 :에 따라 이미 datetime.date
두 개의 인스턴스가있는 경우
d_today = date.today()
d_ref = d_today - BDay(66)
lastDateData = dates[0]
avgArray = []
while (d_ref >= lastDateData):
avg_data = [x for x in stockData_sorted if (x[0] >= d_ref and x[0] <= d_ref + BDay(22))]
avg_dates = [d[0] for d in avg_data]
avg_graphData = [d[1] for d in avg_data]
workingAvg = sum(avg_graphData)/len(avg_graphData)
avgArray.append((d_today,workingAvg))
d_today = d_today - BDay(1)
d_ref = d_ref - BDay(1)
avgArray에서'print ([type (x [0]) '의 결과는 무엇입니까?)'? –
다음은 결과입니다. - - 그래서 datetime 날짜로 변환하기 위해 ".date()"호출을 사용했습니다. (또는 그렇게 생각했습니다) –
JDGD
'avgArray'는 무엇으로 구성되어 있습니까? 이 배열이 만들어진 곳의 코드를 줄 수 있습니까? – armnotstrong