|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
temp = input('请输入一个年份:')
while not temp.isdigit():
print('抱歉,输入不合法,',end='')
temp = input('请输入一个年份:')
y = int(temp)
if isinstance(y/4,int) and isinstance(y/100,float):
print('该年是润年')
else:
if isinstance(y/400,int):
print('该年是润年')
else:
print('该年不是润年')
大佬们,帮忙看一下,我这个代码运行出来为什么400不是闰年了?
- temp = input('请输入一个年份:')
- while not temp.isdigit():
- print('抱歉,输入不合法,',end='')
- temp = input('请输入一个年份:')
- y = int(temp)
- if y%4 == 0 and y % 100 != 0:
- print('该年是润年')
- else:
- if y%400 == 0:
- print('该年是润年')
- else:
- print('该年不是润年')
复制代码
建议换成取余判断
|
|