天道8 发表于 2018-4-5 18:17:51

这个程序相当于一次性用品,怎么让他能重复使用.

temp = input('请输入一个年份:')
while not temp.isdigit():
    temp = input("抱歉,您的输入有误,请输入一个整数:")
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 + ' 不是闰年!')

ba21 发表于 2018-4-5 18:29:20

while True:
temp = input('请输入一个年份:')
while not temp.isdigit():
      temp = input("抱歉,您的输入有误,请输入一个整数:")
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 + ' 不是闰年!')

天道8 发表于 2018-4-5 18:33:47

ba21 发表于 2018-4-5 18:29
while True:
temp = input('请输入一个年份:')
while not temp.isdigit():


谢谢
页: [1]
查看完整版本: 这个程序相当于一次性用品,怎么让他能重复使用.