Python开发,全靠缩进来控制Scope。缩进搞错了,代码也就有问题了。所以写着代码的时候,总是会遇到一个非常常见的问题。TabError: inconsistent use of tabs and spaces in indentation。解决办法无非是代码格式化和肉眼识别。有时候总是会比较顽固的出现。对于初学者来说,这应该是比较头痛的一个问题。

首先设置4空格缩进,在替换所有的tab为4个空格。最后把Tab显示成8个空格。这个建议真的不错,这样在视觉上可以很明显的区分是缩进还是tab。不过因为我的VS Code经常要开发其他语言,第三条设置起来,在有些语言的代码,看上去比较别扭了。找了个折中的办法。

1.设置"editor.tabSize": 4.这是VS Code默认设置,不用改。设置"editor.renderWhitespace": "all"。

2.替换所有的Tab为4Space。按F1,选择“替换缩进为空格”命令。

3.安装Trailing Space插件。这个插件有个很有趣的功能,可以把代码中Tab,空格找出来,并用一个颜色块很明显的显示出来。显示那些内容完全是基于正则表达式的。使用者完全可以自己定义。喜欢怎么花样突出显示都行。

这样,结合VS Code和插件的功能,我们就可以明显的显示出空格,缩进和Tab信息。方便查找那些看不到的缩进带来的Python编译问题。减少一些没必要的时间浪费。

vscode 遇到 TabError: inconsistent use of tabs and spaces in indentation的更多相关文章

  1. Python使用4个空格替换Tab, TabError: inconsistent use of tabs and spaces in indentation。

    问题:以前使用Pycharm和VsCode没遇到问题,使用nodepat++老是提示Tab异常  TabError: inconsistent use of tabs and spaces in in ...

  2. PyCharm出现TabError: inconsistent use of tabs and spaces in indentation最简单实用的解决办法

    本文使用PyCharm的格式化代码功能解决TabError: inconsistent use of tabs and spaces in indentation. 当把代码从别处复制进来PyChar ...

  3. python 报错 TabError: inconsistent use of tabs and spaces in indentation

    写python的时候如果出现如题的错误 TabError: inconsistent use of tabs and spaces in indentation 意为:制表符错误:缩进中制表符和空格使 ...

  4. Python之TabError: inconsistent use of tabs and spaces in indentation和ModuleNotFoundError:No module named 'win32api'

    1.TabError: inconsistent use of tabs and spaces in indentation 这是我的代码,感觉没啥不对, 后来运行之后出现了下面的错误,我也是弄了好久 ...

  5. python运行错误---TabError: Inconsistent use of tabs and spaces in indentation

    本文转载于:http://blog.csdn.net/sinat_36384705/article/details/71155379 首先这个错误的意思是:在缩进的时候,使用了错误的空格和tab 我使 ...

  6. Python程序调试-TabError: inconsistent use of tabs and spaces in indentation

    报错信息:TabError: inconsistent use of tabs and spaces in indentation 说明:代码缩进统一使用Tab键或空格键,不能混用. 解决办法: 1. ...

  7. Python文件运行时报TabError: inconsistent use of tabs and spaces in indentation

    1. 问题描述 Python文件运行时报TabError: inconsistent use of tabs and spaces in indentation 2. 问题原因 tab 和 space ...

  8. python错误提示“TabError: inconsistent use of tabs and spaces in indentation”

    在遍历打印10以内的奇数是出现“TabError: inconsistent use of tabs and spaces in indentation”的错误提示: 代码如下: 第一感觉没什么错误, ...

  9. Python中出现“TabError: inconsistent use of tabs and spaces in indentation”问题的解决

随机推荐

  1. UVA10140PrimeDistance题解--质数/技巧

    题目链接 https://www.luogu.org/problemnew/show/UVA10140 分析 \(L,R\)都很大,显然不能直接筛出\(L,R\)区间中的质数,这里需要一个结论 结论 ...

  2. 6. Java基本数据类型

    Java 基本数据类型 变量就是申请内存来存储值.也就是说,当创建变量的时候,需要在内存中申请空间. 内存管理系统根据变量的类型为变量分配存储空间,分配的空间只能用来储存该类型数据. 因此,通过定义不 ...

  3. css的一些样式

    input标签中的一些样式: <input type="text">:表示输入文本 <input type="password">:表示 ...

  4. java 日期。时间

    友情链接: https://www.cnblogs.com/wanson/articles/10818955.html

  5. MySQL数据库常见问题1:关于 “ MySQL Installer is running in Community mode ” 的解决办法

     现象: MYSQL在安装完成后,系统能正常运行,但是第二天出现了如下一个提示框,如下图:  给个人人都看得懂的如下图: 解决办法:      这个是新版本MySQL服务自带的一个定时任务,每天23: ...

  6. dedeampz 套件关于PHP开启curl方法

    php开启curl方法主要用到三个文件libeay32.dll,php_curl.dll,ssleay32.dll 打开dede的安装目录,更改对应版本PHP中的php.ini文件,在 ; exten ...

  7. 高级IO——文件锁

    文件锁也被称为记录所,文件锁如果深讲的话,内容不少(比如文件锁最起码分为了建议锁和强制性锁,暂时挖坑,后面填). 文件锁作用 顾名思义,就是用来保护文件数据的.当多个进程共享读写同一个文件时,为了不让 ...

  8. 设计模式之Template Method

    1.设计模式的使用场景 模板方法模式(Template Method) 解释一下模板方法模式,就是指:一个抽象类中,有一个主方法,再定义1…n个方法,可以是抽象的,也可以是实际的方法,定义一个类,继承 ...

  9. 菜单项(Menu)的初步认识 以及 多级菜单(SubMenu)的初步认识

    MainActivity.class public class MainActivity extends AppCompatActivity { private TextView textView; ...

  10. shell读取或者修改ini文件

    cfg_find(){ file_name=$1 labelname=$2 key=$3 labelline=$(grep -n "^\[.*\]$" $file_name | a ...