|
|

楼主 |
发表于 2017-11-30 11:33:09
|
显示全部楼层
temp = input("请输入一个年份:")
while not temp.isdigit():
temp = input("输入有误,请重新输入")
year=int(temp)
if year/400 == int(year/400):
print(year + '是闰年!')
else:
if (year/4 == int(year/4)) and (year/100 != int(year/100)):
print(year + '是闰年!')
else:
print(year + '不是闰年!')
以上是改成year的代码报错信息如下
请输入一个年份:1995
Traceback (most recent call last):
File "C:/Users/33544/PycharmProjects/young/young.py", line 11, in <module>
print(year + '不是闰年!')
TypeError: unsupported operand type(s) for +: 'int' and 'str'
|
|