【问题标题】:IndentationError: expected an indented block, but it seems correctIndentationError:需要一个缩进块,但它似乎是正确的
【发布时间】:2019-10-13 09:27:22
【问题描述】:

在我提供的代码中有一个

>IndentationError in line 10, or at the END of:

> while ((while_bolian == "") and (correct_count >= 0) and (total_count != 0)) or ((while_bolian == True) and (correct_count >= 0) and (total_count != 0)):

但是我的所有缩进看起来都是正确的,我使用的是 pycharm,如果我将光标放在上面的代码行之后,它会显示 Indent Expected

我已经对此错误进行了研究,但似乎没有任何帮助解决这个问题。

    total_count = int(input("how many questions do you want to be in the quizz \n10.\n50.\n100.\n:"))
    try:
        while ((while_bolian == "") and (correct_count >= 0) and (total_count != 0)) or ((while_bolian == True) and (correct_count >= 0) and (total_count != 0)):
    except ValueError:
        print("please enter a question limit")

>     line 10
        except ValueError:
        ^
IndentationError: expected an indented block

> Process finished with exit code 1

【问题讨论】:

  • 您可以为您使用的语言添加标签吗?通过指定编码的语言,您可能会找到更好的帮助。
  • 除了必须与 try 相同的缩进
  • 是的,很抱歉刚刚在脚本编辑器中错误地复制到 web-sight 中,它在同一个缩进中。

标签: python indentation expected-exception


【解决方案1】:

while 需要像 pass 这样的指令,带有额外的缩进。
现在while 尝试运行except
参见例如Python syntax for an empty while loop

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-18
    • 2018-02-25
    • 2018-11-22
    • 2022-12-31
    • 1970-01-01
    相关资源
    最近更新 更多