廖国东 发表于 2020-4-10 09:41:20

Python这也太怪了吧

这是代码1
while True:
        temp = input('请输入一个整数')
      while not temp.isdigit():
              temp = input("输入错误,请重新输入。")
      secret = int(temp)
      while secret > 100 or secret < 0:
      
                temp = input("请输入0到100之前的数字。")
              secret = int(temp)
      
   
      if secret>80 and secret <= 100:
              print("A")
      elif secret<=80 and secret>60:
              print("B")
      elif secret>40 and secret<=60:
              print("C")
      else:
              print("D")


这是代码二
while True:
        temp = input('请输入一个整数')
      while not temp.isdigit():    # 更改
              temp = input("输入错误,请重新输入。")
      secret = int(temp)
      while secret > 100 or secret < 0:
              temp = input("请输入0到100之前的数字。")    # 更改
              secret = int(temp)    # 更改

      if secret > 80 and secret <= 100:
              print("A")
      elif secret <= 80 and secret > 60:
                 print("B")
      elif secret > 40 and secret <= 60:
              print("C")
      else:
              print("D")



天啊,这明明一样啊,,,为什么我的运行不了,,代码一是我的,代码二是某版主更改过的,,,为什么代码二可以运行,代码一却错误??
这两个代码哪里错误了吗?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????一脸懵逼

BngThea 发表于 2020-4-10 09:44:27

检查一下缩进,标点符号括号是否是英文等

heidern0612 发表于 2020-4-10 09:45:51

检查下你报错的信息,有提示。

qiuyouzhi 发表于 2020-4-10 09:53:23

报错信息?
我这里没有问题

永恒的蓝色梦想 发表于 2020-4-10 09:53:31

代码没问题,我这正常跑

廖国东 发表于 2020-4-10 10:04:38

woc卧槽,,,我把外壳关了,啊然后打开,就成功了,哈哈哈
页: [1]
查看完整版本: Python这也太怪了吧