Python报错'str'object has no attribute 'today'


def get_count():
  delta = today - datetime.strptime(start_date, "%Y-%m-%d")
  return delta.days


def get_birthday():
  next = datetime.strptime(str(date.today.year) + "-" + birthday, "%Y-%m-%d")
  if next < datetime.now():
    next = next.replace(year=next.year + 1)
  return (next - today).days

在运行以上代码时报错 求指教

你这个date是在那定义的?是个全局变量?

date是什麽类型呢?错误提示date是字符串,没有today这个属性。你给date传递的是字符串,不是date类型