Python 缩进问题-inconsistent use of tabs and spaces in indentation.原因及解决方法

简介: Python 缩进问题-inconsistent use of tabs and spaces in indentation.原因及解决方法

TabError: inconsistent use of tabs and spaces in indentation

这个问题是说用了制表符做了python的缩进。

python的缩进是4个空格算一个缩进,如果不是4个空格就会有问题。

正确的缩进我们选中是分格的,一共4个空格,如果1个的话应该就是tab符了。

image.png

我们编写python的话可以改变编辑器的tab键对应4个空格就好了。

Geany编辑器设置:

如果没有马上生效的话,设置【项目-使用默认缩进】即可;

如果已经有很多缩进是制表符,可以设置【文档-替换制表符为空格】即可;

image.png

注: 如果上面的方法设置默认缩进后不生效,可以把这个 用 Tab 键缩进 选项取消试下。

image.png

喜欢的点个赞❤吧!


目录
相关文章
|
11天前
|
消息中间件 存储 Python
详解Python TimedRotatingFileHandler多进程环境下的问题和解决方法
`TimedRotatingFileHandler`在单进程应用中非常有用,但在多进程环境下直接使用可能会遇到挑战。以上提到的方案可以根据具体情况选取,解决在多进程环境下的日志文件管理问题。综合考虑,采用外部日志管理工具或集中式日志记录方案通常更为稳健和有效,尤其适用于大型或复杂的系统架构。
14 3
|
26天前
|
IDE Java 开发工具
python缩进错误(IndentationError)
【7月更文挑战第12天】
71 10
|
30天前
|
自然语言处理 Java 开发工具
【Python】已解决Resource averaged_perceptron_tagger not found. Please use the NLTK Downloader to obtain t
【Python】已解决Resource averaged_perceptron_tagger not found. Please use the NLTK Downloader to obtain t
42 0
|
30天前
|
IDE 开发工具 Python
【Python】已解决:IndentationError: unindent does not match any outer indentation level
【Python】已解决:IndentationError: unindent does not match any outer indentation level
16 0
|
30天前
|
自然语言处理 Python
【Python】已解决:Resource stopwords not found. Please use the NLTK Downloader to obtain the resource:
【Python】已解决:Resource stopwords not found. Please use the NLTK Downloader to obtain the resource:
34 0
|
30天前
|
IDE 开发工具 Python
python中语法缩进错误处理
【7月更文挑战第8天】
26 2
|
1月前
|
监控 开发者 Python
【Python】已解决:WARNING: This is a development server. Do not use it in a production deployment. Use a p
【Python】已解决:WARNING: This is a development server. Do not use it in a production deployment. Use a p
51 0
|
1月前
|
自然语言处理 Python
【Python】已解决:Resource punkt not found. Please use the NLTK Downloader to obtain the resource:
【Python】已解决:Resource punkt not found. Please use the NLTK Downloader to obtain the resource:
57 1
|
3月前
|
IDE 开发工具 Python
Python应用语法中缩进错误
【5月更文挑战第18天】
23 1
|
3月前
|
Python
Python应用中语法不正确的缩进
【5月更文挑战第17天】
23 1