python:IndentationError: unexpected indent

python对格式要求很严格,今天遇到了IndentationError: unexpected indent错误才知道他是多么的严格.

print(‘aaa‘)

print(‘aaa‘)

下面的这句就报错IndentationError: unexpected indent,原因是多了一个空格!!!

出现这个错误就要知道python编译器是在告诉你:::: 你的文件里格式不对了,可能是tab和空格没对齐的问题,你需要检查下tab和空格了 。

时间: 2024-08-08 01:13:26

python:IndentationError: unexpected indent的相关文章

Python脚本运行出现语法错误:IndentationError:unexpected indent

对于py来说典型错误就是缩进,,烦不胜烦,整理一下解决方法:一个python脚本,本来都运行好好的,然后写了几行代码,而且也都确保每行都对齐了,但是运行的时候,却出现语法错误: IndentationError: unexpected indent [解决过程] 1.对于此错误,最常见的原因是,的确没有对齐.但是我根据错误提示的行数,去代码中看了下,没啥问题啊. 都是用TAB键,对齐好了的,没有不对齐的行数啊. 2.以为是前面的注释的内容影响后面的语句的语法了,所以把前面的注释也删除了. 结果还

python中遇到的问题:IndentationError: unexpected indent

在Python中写下列代码的时候,出现错误:IndentationError: unexpected indent 分析:IndentationError是缩进的错误,查看源代码发现names开始的这一行确实是有缩进了.但是为什么不能缩进呢?网上的说法是Python是一种对缩进非常敏感的语言,最常见的情况是tab和空格的混用会导致错误,或者缩进不对. ok,知道了问题所在,于是将names前面的空格去掉,再运行一次就没有问题了. 原文地址:https://www.cnblogs.com/yyl6

IndentationError: unexpected indent python

都知道python是对格式要求很严格的,写了一些python但是也没发现他严格在哪里,今天遇到了IndentationError: unexpected indent错误我才知道他是多么的严格. 以后遇到了IndentationError: unexpected indent你就要知道python编译器是在告诉你“Hi,老兄,你的文件里格式不对了,可能是tab和空格没对齐的问题,你需要检查下tab和空格了”. 举例: def MyFirstFunction(): print('This is m

[每日一记] Python报错 IndentationError: unexpected indent

IndentationError: unexpected indent 代码缩进出现错误 今天这个报错的原因是,早些时候的代码里Tab和空格混起来用了,,,[不是我...是编辑器的锅 不过我已经把Sublime Text 2的Tab键配置为4个空格了(详见上一篇随笔),以后应该不会出现类似错误.

IndentationError: unexpected indent

p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica } p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica; color: #0000ff } p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica; background-color: #ffffff } span.s1 { ba

python3.4 编译时提示错误 IndentationError: unexpected indent

Farm Tour Description When FJ's friends visit him on the farm, he likes to show them around. His farm comprises N (1 <= N <= 1000) fields numbered 1..N, the first of which contains his house and the Nth of which contains the big barn. A total M (1 &

python IndentationError: unexpected indent

可以看到print line下面那一行的前面不是tab键,而是4个点,并且怎么改也改不回来. 我自己发现这是你自己在写一个新程序的时候,到新的一行,没用tab,而是用4个点代替.后面编译运行,或者写程序写到后面,前面这个你就算怎么改也改不了.

Python脚本运行出现语法错误:IndentationError: unindent does not match any outer indentation level(转)

[问题] 一个python脚本,本来都运行好好的,然后写了几行代码,而且也都确保每行都对齐了,但是运行的时候,却出现语法错误: IndentationError: unindent does not match any outer indentation level [解决过程] 1.对于此错误,最常见的原因是,的确没有对齐.但是我根据错误提示的行数,去代码中看了下,没啥问题啊. 都是用TAB键,对齐好了的,没有不对齐的行数啊. 2.以为是前面的注释的内容影响后面的语句的语法了,所以把前面的注释

Python脚本运行出现语法错误:IndentationError: unindent does not match any outer indentation level

[问题] 一个python脚本,本来都运行好好的,然后写了几行代码,而且也都确保每行都对齐了,但是运行的时候,却出现语法错误: IndentationError: unindent does not match any outer indentation level [解决过程] 1.对于此错误,最常见的原因是,的确没有对齐.但是我根据错误提示的行数,去代码中看了下,没啥问题啊. 都是用TAB键,对齐好了的,没有不对齐的行数啊. 2.以为是前面的注释的内容影响后面的语句的语法了,所以把前面的注释