python today is the day

mission details

Enter the year/month/day (separated by slashes), output the date is the day of the year? (This question guarantees that the year, month, and day used in the test are all legal input) ‬‪‬‪‬‪‬‪‬‮‬‫‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‪‬

code show as below:

date = input()
list = date.split('/')
year = int(list[0])
month = int(list[1])
day = int(list[2])
dm = [31,28,31,30,31,30,31,31,30,31,30,31]
if year % 400 == 0 or (year % 4 == 0 and year % 100 !=0):
    dm[1] = 29
if month == 1:
    n = day
else:
    n = sum(dm[0:month - 1 ]) + day 
print(f'{year}年{month}月{day}日是{year}年第{n}天')

Tears are also growth.

Tears are also growth

Guess you like

Origin blog.csdn.net/m0_70456205/article/details/129468517