简体   繁体   中英

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

        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 )

If you use vim as your text editor you can fix this with ':retab'

Welcome to SO.

It's your indentation. If you're using PyCharm you can reformat your code and or auto-indent the lines.

In the taskbar: code -> auto-indent lines.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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