IndentationError:意外缩进Python 3错误

问题描述

使用以下python 3代码:

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

我收到此错误

IndentationError: unexpected indent

该如何解决?

解决方法

正确

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

,

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

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

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...