python 获取时间的差
程序员文章站
2024-01-29 10:25:16
...
import datetime
today = datetime.datetime.today().replace(microsecond=0)
print(today)
outday = datetime.datetime(2019, 1, 22, 11, 58, 11)
print(outday)
days = (today - outday).days
seconds = (today - outday).seconds
minute, seconds = divmod(seconds, 60)
hour, minute = divmod(minute, 60)
surplus_hour = hour
surplus_minute = minute
surplus_time_str = '{}天{}小时{}分'.format(days, surplus_hour, surplus_minute)
print(surplus_time_str)
上一篇: react受控组件与非受控组件
下一篇: Markdown 目录