|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
while True:
print('请输入一个年份(按a退出):',end='')
year = input()
if year.lower() == 'a':
break
elif not year.isdigit():
print('抱歉,您的输入有误',end='')
continue
temp = int(year)
if temp/400 == int(temp/400):
print(year + '是闰年!')
else:
if (temp/4 == int(temp/4)) and (temp/100 != temp/100):
print(year + '是闰年!')
else:
print(year + '不是闰年!')
while 1 == 1:
print('请输入一个整数(按q退出):',end='')
temp = input()
if temp.lower()=='q':
break
elif not temp.isdigit():
print('抱歉,您的输入有误,',end='')
continue
year = int(temp)
if year/400 == int(year/400):
print(temp + ' 是闰年!')
else:
if (year/4 == int(year/4)) and (year/100 != int(year/100)):
print(temp + ' 是闰年!')
else:
print(temp + ' 不是闰年!')
以上两段代码是判断是不是闰年的,可是第一段代码运行时无论输入什么年份都会判断成不是闰年,第二段代码是正常的,可以判断出闰年和不是闰年,不知道第一段代码哪里出了问题?求指教
if (temp/4 == int(temp/4)) and (temp/100 != int(temp/100)):
|
|