IndentationError:意外缩进Python 3错误

时间:2020-08-29 04:31:11

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

使用以下python 3代码:

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

我收到此错误

IndentationError: unexpected indent

该如何解决?

2 个答案:

答案 0 :(得分:0)

正确

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

答案 1 :(得分:0)

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

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