How do I find out how much time is left until the new year?

How can I find out how many days are left until the new year on. Python programming language? In numeric format, so that you can display this message on the screen: how many days are left until the new year.

Author: S. Nick, 2020-12-25

1 answers

As an option:

import datetime


now = datetime.datetime.today()
NY = datetime.datetime(2021, 1, 1)
d = NY-now  
                    
mm, ss = divmod(d.seconds, 60)
hh, mm = divmod(mm, 60)

print('До нового года: {} дней {} часа {} мин {} сек.'.format(d.days, hh, mm, ss))
 4
Author: S. Nick, 2020-12-25 01:31:35