【问题标题】:IndentationError: unexpected indent Python 3 Error [duplicate]IndentationError:意外缩进Python 3错误[重复]
【发布时间】:2020-12-17 23:00:39
【问题描述】:

使用以下 python 3 代码:

print("The nodes visited in the frontier are:", end = " ")

我收到这个错误

IndentationError: unexpected indent

如何解决这个问题?

【问题讨论】:

  • 一定有一些语句你可能用空格缩进,而有些则用制表符缩进。所以有一个错误。
  • 在此处添加完整程序

标签: python python-3.x error-handling whitespace indentation


【解决方案1】:

我认为你应该在 print() 之前删除空格。根据你的说法,我想这很好用

print("The nodes visited in the frontier are:", end = " ")  #removed the space in the beginning

【讨论】:

  • 还是有错误
【解决方案2】:

正确

if 5 > 2:
    print("Five is greater than two!")

不正确

if 5 > 2:
print("Five is greater than two!")

在这里找到更多信息https://docs.python.org/2.0/ref/indentation.html 或者这里(2.1.8.缩进),https://docs.python.org/3/reference/lexical_analysis.html#line-structure

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-04-24
    • 1970-01-01
    • 1970-01-01
    • 2018-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多