Если вы хотите распечатать обратный отсчет, как часы судного дня, вам нужно проанализировать значение timedelta.
Это то, что вы ищете?
import time
import datetime
def countdown(stop):
while True:
difference = stop - datetime.datetime.now()
count_hours, rem = divmod(difference.seconds, 3600)
count_minutes, count_seconds = divmod(rem, 60)
if difference.days == 0 and count_hours == 0 and count_minutes == 0 and count_seconds == 0:
print("Good bye!")
break
print('The count is: '
+ str(difference.days) + " day(s) "
+ str(count_hours) + " hour(s) "
+ str(count_minutes) + " minute(s) "
+ str(count_seconds) + " second(s) "
)
time.sleep(1)
end_time = datetime.datetime(2019, 3, 31, 19, 35, 0)
countdown(end_time)
# sample output
The count is: 44 day(s) 23 hour(s) 55 minute(s) 55 second(s)
The count is: 44 day(s) 23 hour(s) 55 minute(s) 54 second(s)
The count is: 44 day(s) 23 hour(s) 55 minute(s) 53 second(s)
The count is: 44 day(s) 23 hour(s) 55 minute(s) 52 second(s)
The count is: 44 day(s) 23 hour(s) 55 minute(s) 51 second(s)