|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
如题,下面这个为啥不对啊TAT
temp = input('请输入一个年份:')
while not temp.isdigit():
temp = input('抱歉,您的输入有误,请输入一个年份:')
year = int(temp)
if isinstance((year/400), int):
print(temp + '是闰年!')
else:
if (isinstance((year/4), int) and (not isinatance((year/100), int)):
print(temp + '是闰年!')
else:
print(temp + '不是闰年!')
本帖最后由 2289001949 于 2018-3-21 09:02 编辑
- temp = input('请输入一个年份:')
- while not temp.isdigit():
- temp = input('抱歉,您的输入有误,请输入一个年份:')
- year = int(temp)
- if year%400==0:
- print(temp + '是闰年!')
- elif year%4==0 and year%100!=0 :
- print(temp + '是闰年!')
- elif year%4!=0:
- str(temp)
- print(temp + '不是闰年!')
复制代码
你完全可以用求余的方法来做的
python里 整数相除得到的是浮点型的
用shell试一下8/4 是得到2.0的
|
|