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. eventFlow 系列 <一> 入门

    var exampleId = ExampleId.New; var commandBus = resolver.Resolve<ICommandBus>(); ,) var execut ...

  2. tinymce富文本是在modal框中弹出显示的问题

    记录一下,在用tinymce富文本的时候,由于是用在modal 上的,始终无法获取焦点,后来才发现问题出在tinymce在modal前创建了,所以导致这个问题,解决方案就是用 v-if="v ...

  3. iOS UIControl 事件的说明(转)

    在控件事件中,简单解释下下面几个事件. 说明:由于是在“iOS 模拟器”中测试的,所以不能用手指,只能用鼠标. 1)UIControlEventTouchDown 指鼠标左键按下(注:只是“按下”)的 ...

  4. css流程图

     图片链接:https://mp.processon.com/view/link/5da65435e4b0ea86c2b1fb05 之前是图片链接是有点问题,不知道什么原因被删除了,现在已经更新了,如 ...

  5. XWork配置示例

    <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE validators PUBLIC       ...

  6. ARM与x86 CPU架构对比

    CISC(复杂指令集计算机)和RISC(精简指令集计算机)是当前CPU的两种架构.它们的区别在于不同的CPU设计理念和方法.早期的CPU全部是CISC架构,它的设计目的是CISC要用最少的机器语言指令 ...

  7. vue+element-ui 项目中实现复制文字链接功能

    需求: 点击复制按钮,复制一个链接 在GitHub上找到一个clipboard组件,功能比较齐全 使用方法:   安装 npm i clipboard --save HTML <template ...

  8. 报错处理(UnicodeEncodeError: 'gbk' codec can't encode character '\xa0' in position 2: ill egal multibyte sequence)

    参照文[https://blog.csdn.net/Dillon2015/article/details/53204955]的说法, 第一个错 [UnicodeEncodeError:'gbk' co ...

  9. GOLANG多态的特征是通过接口来实现的 GOLANG多态形式之一:多态参数

    GOLANG多态的简单实现 //多态的特征是通过接口来实现的 //多态形式之一:多态参数 package main import( "fmt" _"sort" ...

  10. Caffe---Pycaffe转换均值文件:xxx_mean.binaryproto成为xxx_mean.npy

    Pycaffe转换均值文件:xxx_mean.binaryproto成为xxx_mean.npy 为什么需要mean.binaryproto转mean.npy? 使用Caffe的C++接口进行操作时, ...