计算从某日期到2018年经过了多长时间

使用终端来输入数据。

input输入

# curr_year = input("input the year :")
# print 'it has been ' ,2018-curr_year, ' years.'
# print 'it has been '+ str(2018-curr_year)+ ' years.'


curr_year = input( "input the year :")
curr_month = input( "input the month :")
curr_day = input( "input the day :")
print 'it has been ' ,( 2018-curr_year)* 12+curr_month, ' month.'
print 'it has been '+ str(( 2018-curr_year)* 365+(curr_month- 1)* 30+curr_day)+ ' days.'
if curr_month >= 3:
print 'it has been ' ,( 2018-curr_year)* 365+(curr_month- 1)* 30+curr_day-( 1*curr_year- 2011+ 1), ' day.'
else:
print 'it has been ' ,( 2018-curr_year)* 365+(curr_month- 1)* 30+curr_day- 1*(curr_year- 2012+ 1), ' day.'
value_a = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
sum= 0
for i in range( 1,curr_month):
sum= sum+value_a[i- 1]
i=i+ 1

print 'it has been ' ,( 2018-curr_year)* 365+ sum+curr_day, ' day.'


猜你喜欢

转载自blog.csdn.net/piaoyu94/article/details/79299735
今日推荐