Home > other >  Python calculate number of days
Python calculate number of days

Time:09-24

Friends, please give directions, if you are willing to help me, I am very grateful, I soon in CSDN, also won't stick, please tell me how to knot, knot stick I gave you, thank you

CodePudding user response:

 
The import time
I=input (" please enter the date format is year - month - day], such as the 2020-3-1: \ n ',)
Y, m, d=(int (v) in the for v i. plit (' - '))
T=(y, m, d, 0, 0, 1, 0, 0, 0)
The SEC=time. Mktime (t)
Tm_yday=time. Localtime (SEC). Tm_yday

Print (time. Localtime (SEC))
Print (' today is the first of the year '{} days. The format (tm_yday))


Please enter the date format is year - month - day], for example: 2020-3-1
The 2020-1-25
Time. Struct_time (tm_year=2020, tm_mon=1, tm_mday=25, tm_hour=0, tm_min=0, tm_sec=1, tm_wday=5, tm_yday=25, tm_isdst=0)
Today is the 25th day of the year



  • Related