【pycharm 报错】TabError: inconsistent use of tabs and spaces in indentation

报错:

Traceback (most recent call last):
  File "/home/fuxueping/sdb/software/pycharm-community-2020.2/plugins/python-ce/helpers/pydev/pydevd.py", line 1448, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/home/fuxueping/sdb/software/pycharm-community-2020.2/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/home/fuxueping/sdb/git_Lab/code/crnn_recognition/train_new.py", line 46
    n_class = len(char_set)
                          ^
TabError: inconsistent use of tabs and spaces in indentation

报错原因:这个报错的意思是说IDE分不清tab和空格,说明你的代码中混用了tab和空格。

解决办法:格式化代码,具体操作如下

左键点击项目栏的工程名;

【pycharm 报错】TabError: inconsistent use of tabs and spaces in indentation_第1张图片

 选中工具栏的code-》Reformat Code:

【pycharm 报错】TabError: inconsistent use of tabs and spaces in indentation_第2张图片

 出现以下界面,点击‘run’:

【pycharm 报错】TabError: inconsistent use of tabs and spaces in indentation_第3张图片

然后查看代码中的空格是否合理,进行修改就可以了; 

 

你可能感兴趣的:(tool)