简体   繁体   English

使用标签不一致 python

[英]inconsistent use of tabs python

I am getting the following error: How can I fix it?我收到以下错误:我该如何解决?

File "/Users/rjeudy/PycharmProjects/virtualenv/virtualenv/src/products/forms.py", line 35 def clean_title(self, *args, **kwargs): ^ TabError: inconsistent use of tabs and spaces in indentation文件“/Users/rjeudy/PycharmProjects/virtualenv/virtualenv/src/products/forms.py”,第 35 行 def clean_title(self, *args, **kwargs):^ TabError:缩进中制表符和空格的使用不一致

        def clean_title(self, *args, **kwargs):
            title = self.cleaned_data.get("title")
            if "CFE" in title:
                return title

The problem is that you are using both tabs and spaces inconsistently.问题是您不一致地使用制表符和空格。

( https://medium.com/@peey/what-is-the-inconsistent-use-of-tabs-and-spaces-in-indentation-error-and-why-is-it-caused-f3bbb8b2568b ) https://medium.com/@peey/what-is-the-inconsistent-use-of-tabs-and-spaces-in-indentation-error-and-why-is-it-caused-f3bbb8b2568b

If you use vim as your text editor you can fix this with ':retab'如果您使用 vim 作为您的文本编辑器,您可以使用 ':retab' 修复它

Welcome to SO.欢迎来到 SO。

It's your indentation.这是你的缩进。 If you're using PyCharm you can reformat your code and or auto-indent the lines.如果您使用的是 PyCharm,您可以重新格式化您的代码和/或自动缩进这些行。

In the taskbar: code -> auto-indent lines.在任务栏中:代码 -> 自动缩进行。

https://www.jetbrains.com/help/pycharm/reformat-and-rearrange-code.html https://www.jetbrains.com/help/pycharm/reformat-and-rearrange-code.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM