| 
 | 
 
 
发表于 2017-4-10 21:31:09
|
显示全部楼层
 
 
 
- #this file is used to calculate someone attend days
 
 - #if someone's entry day is 2014.8.18
 
 - #user input random days followed year.month.day format
 
 - #the program calculated someone's attend days
 
 - print('wonderful enjoy will start soon,please follow below tips accomplish!!')
 
 - print('this version start day is 2014.8.18')
 
 - print('please input end day')
 
 - Y = input('please input years you think:')
 
 - M = input('please input months you think:')
 
 - D = input('please input days you think:')
 
 - GAP_day = 0
 
 - temp0_gap_day = 0
 
 - temp1_gap_day = 0
 
 - temp2_gap_day = 0
 
 - leap_year = [31,29,31,30,31,30,31,31,30,31,30,31]
 
 - nonleap_year = [31,28,31,30,31,30,31,31,30,31,30,31]
 
 - if int(Y) < 2014 :
 
 -     print('this is a invalid year number,should greater than 2014,please restart')
 
 - elif int(Y) == 2014:
 
 -     if int(M) == 8:
 
 -         if int(D) >= 18 :
 
 -             GAP_day = int(D) - 17
 
 -         else:
 
 -             print('warning:day number should greater than 18\nplease input day you think again:')
 
 -     elif int(M) < 8:
 
 -         print('warning:month number should greater than 8')
 
 -     elif int(M) > 8 and int(M) <= 12 :
 
 -         for i in range(7,int(M)-1):
 
 -                   temp0_gap_day = temp0_gap_day + nonleap_year[i]
 
 -     GAP_day = temp0_gap_day + int(D) - 17
 
 -     print('小陆的入职时间是:%d天'%GAP_day)
 
 - elif int(Y) > 2014:
 
 -     for i in range(0,((int(Y)-2014))):
 
 -         if (2014+i)%4 == 0 and (2014+i)%100 != 0 :
 
 -                    #print('current year:%d'%(2014+i))
 
 -                    #print('this year is a leap year!')
 
 -                    temp1_gap_day += 366
 
 -         else:
 
 -                    #print('current year:%d'%(2014+i))
 
 -                    #print('this year is a nonleap year!')
 
 -                    temp1_gap_day += 365
 
 -     #print('first part gap_day is:%d'%temp1_gap_day)
 
 -     if int(Y)%4 == 0 and int(Y)%100 != 0 :
 
 -                    #print('current year:%d'%int(Y))
 
 -                    #print('this year is a leap year!')
 
 -                    for i in range(0,int(M)-1):
 
 -                        temp2_gap_day = temp2_gap_day + leap_year[i] + int(D)
 
 -                    
 
 -     else:
 
 -                    #print('current year:%d'%int(Y))
 
 -                    #print('this year is a nonleap year!')
 
 -                    for i in range(0,int(M)-1):
 
 -                        temp2_gap_day = temp2_gap_day + nonleap_year[i] + int(D)
 
 -     #print('second part gap_day is:%d'%temp2_gap_day)
 
 -     GAP_day = temp1_gap_day + temp2_gap_day - 230
 
 -     print('小陆的入职时间是:%d天'%GAP_day)
 
 -                    
 
 -     
 
 
  复制代码 
 
比较繁琐的做法!! |   
 
评分
- 
查看全部评分
 
 
 
 
 
 |