2374668771 发表于 2018-4-11 00:08:42

python

temp = input("请输一个年份:")
while not temp.isdigit():
      year = int("抱歉,您的输入有误,请输入一个整数:")
      year = int(temp)
      if year/400 == int (year/400):
            print(temp + '是闰年')
      elif (year/4 == int(year/4))and(year/100 != int(year/100)):
            print(temp+'是闰年')
      else :
            print(temp+'是闰年')
      

      

各位,鱼大大,为什么无法运行??????

BngThea 发表于 2018-4-11 06:41:35

year的第一条赋值语句用input,而不是int
后面的缩进和while平齐

wellwellstudy 发表于 2018-4-11 08:57:22

year = int(temp) 开始后面的语句要和while语句平齐。

year = int("抱歉,您的输入有误,请输入一个整数:")————改为 temp = input("抱歉,您的输入有误,请输入一个整数:")

页: [1]
查看完整版本: python