'''获取键盘中输入的日期,提取年份,然后判断这个年份是不是闰年'''
import datetime,time,types
global format_date
format_date="%Y-%m-%d"
def isLeap_year():
year=dateConfirmation()
print 'year =',year
if type(year) is types.IntType:
print 'yearInt', year
judge(year)
else:
print year,'is not a Integer'
year = int(year)
judge(year)
return True
# 输入数据
def input_date():
global date
date = raw_input("please enter date, format is Year-Month-day:")
return date
# 处理输入的日期
def dateConfirmation():
try:
date1= input_date()
print '你输入的日期是:',date1,'请确认'
datetime.datetime.strptime(date1,format_date)
year = time.strptime(date1,"%Y-%m-%d")
newYear= "%s" %year.tm_year