Python 减少时间:分钟:秒
我不能以今天的时间扣减为例;2021:04:05时:分:秒形式Python 减少时间:分钟:秒,python,date,deadlines,Python,Date,Deadlines,我不能以今天的时间扣减为例;2021:04:05时:分:秒形式 from datetime import datetime, time leaving_date = datetime.strptime('2021-04-05 00:00:00', '%Y-%m-%d %H:%M:%S') now = datetime.now() print(str"%d hours, %d minutes, %d seconds") 有人能改进我的代码并帮助我吗?谢谢这将以字符串形
from datetime import datetime, time
leaving_date = datetime.strptime('2021-04-05 00:00:00', '%Y-%m-%d %H:%M:%S')
now = datetime.now()
print(str"%d hours, %d minutes, %d seconds")
有人能改进我的代码并帮助我吗?谢谢这将以字符串形式分别为您提供小时、分钟和秒:
hours, minutes, seconds = str(now).split(" ")[1].split(".")[0].split(":")
如何打印?我不知道您使用的是哪个版本的Python。如果它>=3.6,那么
print(f“{hours}hours,{minutes}minutes,{seconds}seconds”)
会起作用。我也是,但是这些变量没有定义,所以如何打印这个lol,因为我想让脚本倒计时到第二天,例如,日期2021:04:05,我想给出多少小时:分钟:第二天到那天为止