开发者

AttributeError: 'datetime.date' object has no attribute 'date'

I have a script like this:

import datetime

# variable cal_start_of_week_date has type <type 'datetime.date'>
# variable period has type <type 'datetime.timedelta'>

cal_prev_monday  = (cal_start_of_week_date - period).date()

When the above statement is executed, I get the 开发者_高级运维error:

AttributeError: 'datetime.date' object has no attribute 'date'

How to fix this?


Stop trying to call the date() method of a date object. It's already a date.


.date() method exists only on datetime.datetime objects. You have object of datetime.date type.

Remove method call and be happy.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜