小编Ken*_*den的帖子

- 不支持的操作数类型:“str”和“datetime.datetime”

我正在尝试编写一个 Python 脚本来倒计时到我的下一个生日。不幸的是,我不断收到此错误消息说明

- 不支持的操作数类型:“str”和“datetime.datetime”

任何帮助,将不胜感激。这是我的代码:

import datetime

birthday = input('Please enter your birthday(mm/dd/yyyy): ')
birthdate = datetime.datetime.strptime(birthday,'%m/%d/%Y').date()

currentDate = datetime.datetime.today()

days = birthday - currentDate
print(days)
Run Code Online (Sandbox Code Playgroud)

python string types for-loop operands

4
推荐指数
1
解决办法
2万
查看次数

标签 统计

for-loop ×1

operands ×1

python ×1

string ×1

types ×1