小编Sup*_* KV的帖子

AttributeError:'datetime.timedelta'对象没有属性'year'

d1 = datetime.strptime(self.current_date, "%Y-%m-%d")
d2 = datetime.strptime(self.dob, "%Y-%m-%d")

current_age = (d1 - d2).year
Run Code Online (Sandbox Code Playgroud)

运行此代码会出现以下错误:

AttributeError: 'datetime.timedelta' object has no attribute 'year'
Run Code Online (Sandbox Code Playgroud)

python python-3.x

1
推荐指数
1
解决办法
6727
查看次数

标签 统计

python ×1

python-3.x ×1