-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path计算日期到天数.py
53 lines (51 loc) · 1.39 KB
/
计算日期到天数.py
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2019/8/14 16:50
# @Author : SeniorZhu1994
# @Email : SeniorZhu1994@foxmail.com
# @Site :
# @File : 计算日期到天数.py
# @Software: PyCharm
# @Describe:
# 判断是否是闰年
def runNianDays(year):
flag = 0
if year % 100 == 0:
if year % 400 == 0:
flag = 1
else:
flag = 0
elif year % 4 == 0:
flag = 1
else:
flag = 0
if flag:
return 366
else:
return 365
if __name__ == '__main__':
output = 0
while True:
try:
# y = int(input())
# m = input()
# d = int(input())
y, m, d = map(int, input().split())
if y and m and d:
month_days_p = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
month_days_r = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
days = runNianDays(y)
if days == 365:
for i in range(m-1):
output +=month_days_p[i]
output_all = output + d
else:
for i in range(m-1):
output += month_days_r[i]
output_all = output + d
print(output_all)
output = 0
else:
break
except:
break