| 12345678910111213141516171819 |
- # -*- coding: UTF-8 -*-
- import datetime
- inp = input('输入时间格式(年-月-日 时:分:秒):')
- nowtime = datetime.datetime.now()
- # restime = datetime.datetime.strptime(inp, '%Y-%m-%d %H:%M:%S')
- restime = datetime.datetime.strptime("2020-09-23 12:00:00", '%Y-%m-%d %H:%M:%S')
- # print (nowtime)
- # print(restime)
- t = restime - nowtime
- print(str(t))
- print(t.days)
- print(t.seconds)
- hour, second = divmod(t.seconds, 3600)
- minute, second = divmod(second, 60)
- data_time = f"{t.days}天{hour}小时{minute}分{second}秒"
- print(data_time)
|