原文链接:http://www.juzicode.com/archives/2201

错误提示:

运行py文件,提示:IndentationError: unexpected indent,提示在第3行遇到非预期的缩进。

Python错误集锦:IndentationError: unexpected indent

 

可能原因:

1、同一个层级的代码行,必须保存缩进一致,上面的代码中第2、3行的层级一样,所以第2、3行的缩进要一致,print函数前面的空格数量要保持一致:

Python错误集锦:IndentationError: unexpected indent

 

解决方法:

1、将第3行和第2行一样顶格写。

Python错误集锦:IndentationError: unexpected indent

相关文章: