Python 4
[Python 100] Python 100
3552
#!/usr/bin/python3
year = int(input('year:\n'))
month = int(input('month:\n'))
day = int(input('day:\n'))
months = (0,31,59,90,120,151,181,212,243,273,304,334)
if 0 < month <= 12:
sum = months[month - 1]
else:
print ('data error')
sum += day
leap = 0
if (year % 400 == 0) or ((year % 4 == 0) and (year % 100 != 0)):
leap = 1
if (leap == 1) and (month > 2):
sum += 1
print ('it is the %dth day.' % sum)
year: 2015 month: 6 day: 7 it is the 158th day.
[Python 100] Python 100
ym
853***[email protected]
#!/usr/bin/python # -*- coding: UTF-8 -*- year=int(raw_input("\n")) month=int(raw_input("\n")) day=int(raw_input("\n")) months1=[0,31,60,91,121,152,182,213,244,274,305,335,366] # months2=[0,31,59,90,120,151,181,212,243,273,304,334,365] # if ((year%4==0)and(year%100!=0)) or((year%100==0)and(year%400==0)): Dth=months1[month-1]+day else: Dth=months2[month-1]+day print "%d"%Dthym
853***[email protected]
pai
646***[email protected]
#!/usr/bin/python # -*- coding: UTF-8 -*- # p = [31,28,31,30,31,30,31,31,30,31,30,31] # w = [31,29,31,30,31,30,31,31,30,31,30,31] # year =int(raw_input(""+'\n')) month =int(raw_input(""+'\n')) day=int(raw_input(""+'\n')) arr=[31,28,31,30,31,30,31,31,30,31,30,31] sum=day for i in range(0,month-1): sum+=arr[i] if year%4==0: if year%100==0 and year%400!=0: print "%d" % sum else: sum=sum+1 print "%d" % sum else: print "%d" % sumpai
646***[email protected]
758***[email protected]
#!/usr/bin/python # -*- coding: UTF-8 -*- # p = [31,28,31,30,31,30,31,31,30,31,30,31] # w = [31,29,31,30,31,30,31,31,30,31,30,31] # year =int(raw_input(":\n")) month =int(raw_input(":\n")) day =int(raw_input(":\n")) # if year % 100 == 0: if year % 400 == 0: d=w else: d=p else: if year % 4 == 0: d=w else: d=p # days = sum(d[0:month-1])+day print "%d.%d.%d%d%s"%(year,month,day,year,days)758***[email protected]
Atom
tum***@126.com
#!/usr/bin/python # -*- coding: UTF-8 -*- year = int(input('')) month = int(input('')) day = int(input('')) total = 0 if year%4 == 0: days = 29 else: days = 28 if year%4 == 0: print year, '2', days, '' else: print year, '2', days, '' if month <= 1: total = day elif month == 2: total = 31 + day elif month == 9 or month == 11: total = (month - 2) * 30 + days + month/2 + day + 1 else: total = (month - 2) * 30 + days + month/2 + day print year, '',month, '', day, ',', total, ''Atom
tum***@126.com
sha***[email protected]
#!/usr/bin/python def isLeapYear(a): if (0 == a%4 or 0 == a%400) and 0 != a%100 : return 1 else: return 0 dict = {1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31} a = int(input("Input year:")) b = int(input("Input month:")) c = int(input("Input day:")) m = 0 k = isLeapYear(a) for i in range(1,b): m = m + dict[i] m = m + isLeapYear(a) + c print(m)sha***[email protected]
shusihui
511***[email protected]
#!/usr/bin/env python # -*- coding: utf-8 -*- year = int(raw_input('year:\n')) month = int(raw_input('month:\n')) day = int(raw_input('day:\n')) days = [31,28,31,30,31,30,31,31,30,31,30,31] if year % 400 == 0 or (year % 4 == 0 and year % 100 != 0): days[2] += 1 now = sum(days[0:month-1])+day print 'it is the %dth day.' %nowshusihui
511***[email protected]
lqy126
412***[email protected]
#!/usr/bin/env python #coding:utf-8 import time import sys reload(sys) sys.setdefaultencoding('utf-8') # 'utf-8' a = raw_input("2017-04-04:") t = time.strptime(a,"%Y-%m-%d") print time.strftime("%j",t).decode('utf-8')lqy126
412***[email protected]
646***[email protected]
#! /usr/bin/env python # coding:utf-8 import time D=raw_input("XXXX-XX-XX") d=time.strptime( D,'%Y-%m-%d').tm_yday print "the {} day of this year!" .format(d)646***[email protected]
cc
123***3.123
Python3
#!/usr/bin/python3 date = input("(yyyy-mm-dd):") y,m,d = (int(i) for i in date.split('-')) sum=0 special = (1,3,5,7,8,10) for i in range(1,int(m)): if i == 2: if y%400==0 or (y%100!=0 and y%4==0): sum+=29 else: sum+=28 elif(i in special): sum+=31 else: sum+=30 sum+=d print("%d"%sum)cc
123***3.123
104***[email protected]
*,*:.()/$:*.*
#!/usr/bin/python # -*- coding: UTF-8 -*- i= int(input('')) j= int(input('')) k= int(input('')) month = [31,28,31,30,31,30,31,31,30,31,30,31] day = 0 if i%4 == 0 or i %400 == 0 and i%100 != 0: # month = month[:j-1] if j >2: #2 day = sum(month)+1+k elif j== 2 and k ==29: # day = sum(month)+1+k else: day = sum(month)+k else: # month = month[:j-1] day = sum(month)+k print('{}'.format(day))104***[email protected]
guanerye
lis***[email protected]
#!/usr/bin/env python #-*- coding:utf-8 -*- import calendar year = int(input("year: ")) month = int(input("month: ")) day = int(input("day: ")) days = 0 if 0 < month <= 12: _, month_day = calendar.monthrange(year, month) if day <= month_day: for m in range(1, month): _, month_day = calendar.monthrange(year, m) days += month_day days += day print days else: print "input day error" else: print "input month error"guanerye
lis***[email protected]
Think-dfrent
iwa***[email protected]
113600*24
#!/usr/bin/env python3 import time def datecount(date): date0=date[0:4]+"-01-01" datet=time.strptime(date,"%Y-%m-%d") # date0t=time.strptime(date0,"%Y-%m-%d") dates=time.mktime(datet) # date0s=time.mktime(date0t) count=(dates-date0s)/(3600*24) #0101 return count+1 a=input("2017-06-16\n") print("{}{}{}".format(a,a[0:4],int(datecount(a))))Think-dfrent
iwa***[email protected]
wel***[email protected]
13650-31
#!/usr/bin/env python #-*- coding:utf-8 -*- print('\n') year = int(input('\n')) month = int(input(':\n')) day = int(input(':\n')) months = [31,28,31,30,31,30,31,31,30,31,30,31] d = 0 if 0<month<=12: if 0<day<=31: d = d + day if month > 2: if (year % 400 == 0) or ((year % 4 == 0) and (year % 100 != 0)): d = d + 1 for i in range(12): if (i+1) < month: d = d + months[i] i = i + 1 print(d) else: print('') else: print('')wel***[email protected]
AKILLII
616***[email protected]
unixUnix
#coding=utf-8 import time print "Please Enter full number just like 02 01 03" y = int(raw_input('Enter the year:')) # m = int(raw_input('Enter the month:')) d = int(raw_input('Enter the day:')) a = (y,m,d,00,00,00,00,00,00) #9 b = (y,01,01,00,00,00,00,00,00) # timestampa = time.mktime(a) #Unix1970.1.1 timestampb = time.mktime(b) timec = int((timestampa - timestampb)/(3600*24)) # print("There are {} days goes by!".format(timec))AKILLII
616***[email protected]
190***[email protected]
python3 time:
import time print(time.strptime('2017-9-20', '%Y-%m-%d')[7])190***[email protected]
.zck
121***[email protected]
Python2.x Python3.x
#!/usr/bin/python # -*- coding: UTF-8 -*- # days = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334] yy = int(input('')) if yy >= 0: mm = int(input('')) if 0 < mm < 13: dd = int(input('')) if ((yy % 4 == 0) and (yy % 100 != 0)) or (yy % 400 == 0): if mm <= 2: sum = days[mm - 1] + dd else: sum = days[mm - 1] + 1 + dd else: sum = days[mm - 1] + dd print('%d' % sum) else: print('') else: print('').zck
121***[email protected]
Echo
csz***[email protected]
#!/usr/bin/python # -*- coding: UTF-8 -*- from functools import reduce year = int(input('2017')) month = int(input('3')) day = int(input('16')) mday = [0,31,28 if year%4 else 29 if year%100 else 28 if year%4 else 29,31,30,31,30,31,31,30,31,30,31] print('{}{}{}{}'.format(year, month, day, reduce(lambda x,y:x+y, mday[:month])+day))Echo
csz***[email protected]
227***[email protected]
import time while 1: try: a=input('yyyy-mm-dd:') b=time.strptime(a,'%Y-%m-%d') # local except ValueError: print('') else: b=time.strptime(a,'%Y-%m-%d') # global dd=time.strftime('%j',b) # yy=time.strftime('%Y',b) # print('%s%s'%(yy,dd)) break227***[email protected]
S
894***[email protected]
#!/usr/bin/python # -*- coding: UTF-8 -*- year = int(input(':')) mon = int(input(':')) day = int(input(':')) Days = [0,31,28,31,30,31,30,31,31,30,31,30,31] if (year % 100 != 0 and year % 4 == 0) or (year % 400 == 0): Days[2] = 29 for each in range(0,mon): day += Days[each] print('%d' %day)S
894***[email protected]