输入某年某月某日,判断这一天是这一年的第几天?

import datetime

import time

dtstr = str(raw_input('Enter  the datetime:(20180514):'))

dt = datetime.datetime.strptime(dtstr,“%Y%m%d”)

another_dtstr = dtstr【:4】 +'0101'

another_dt = datetime.datetime.strptime(another_dtstr,“%Y%m%d”)

print(int((dt-another_dt).days)+ 1)

你可能感兴趣的:(输入某年某月某日,判断这一天是这一年的第几天?)