-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patht004.py
More file actions
38 lines (32 loc) · 851 Bytes
/
Copy patht004.py
File metadata and controls
38 lines (32 loc) · 851 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#coding=utf-8
#输入某年某月某日,判断这一天是这一年的第几天?
daySum = 0
year = int(raw_input("year:"))
month = int(raw_input("month:"))
day = int(raw_input("day:"))
list31 = {1,3,5,7,8,10,12}
list30 = {4,6,9,11}
def isLeap(year):
'''判断某一年是否为闰年,闰年返回1平年返回0'''
leap = 0
if year % 4 ==0:
if year % 100 ==0:
if year % 400 == 0:
leap = 1
else:
leap = 0
else:
leap = 1
else:
leap = 0
return leap
for monthidx in range(1,month):
if(monthidx in list31):
daySum+=31
if(monthidx in list30):
daySum+=30
if(monthidx == 2):
daySum = daySum + 27 + isLeap(year)
daySum+=day
print(isLeap.__doc__)
print('这是一年中的第{}天'.format(daySum))