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. VBA学习资料分享-1

    近年来,人工智能的概念深入人心,许多企业也正逐步或已推行办公自动化,寻求人力时间成本的降低,从而提升效益.对企业来说,要完全使用人工智能将工作流程自动化恐怕是没那么容易的,可以的话成本也不低,所以使用 ...

  2. 爬虫遇到IP访问频率限制的解决方案

    背景: 大多数情况下,我们遇到的是访问频率限制.如果你访问太快了,网站就会认为你不是一个人.这种情况下需要设定好频率的阈值,否则有可能误伤.如果大家考过托福,或者在12306上面买过火车票,你应该会有 ...

  3. LeetCode:596.超过5名学生的课

    题目链接:https://leetcode-cn.com/problems/classes-more-than-5-students/ 题目 有一个 courses 表 ,有: student (学生 ...

  4. Webpack4 splitChunks配置,代码分离逻辑

    博客不知道啥时候写的了,一直在草稿箱没写完,突然感觉今年过去大半了,又没怎么写博客.写写完,有始有终 1.代码分离升级 原来项目代码分离是通过下面的配置,基于bundle-loader插件,通过rou ...

  5. oracle解锁oracle默认用户scott

    oracle中存在一个默认的用户scott,密码为tiger,当在安装oracle时,若未给该账户解锁,则登录该用户时, 会提示被锁定. 如何通过sqlplus命令为scott解锁: 1.C:> ...

  6. LaTeX中Python代码的语法高亮

    LaTeX中Python代码的语法高亮 本文中,"{}"中的字母为LaTeX或Python的包名,只有"Pygments"是Python的包,其他都是LaTeX ...

  7. 了解认识asp.net运行机制

    asp.net  运行机制 下面了解认识httpModule 要创建一个httpModule类 using System;using System.Collections.Generic;using ...

  8. vim文本编辑及文件查找应用3

    文件查找 locate,find两个命令 在文件系统上查找符合条件的文件: 实现工具:locate,find locate命令: 依赖于事先构建好的索引库,索引库可以由下边两种方式构建 系统自动实现( ...

  9. MySQL中DATA类型数据和DATATIME类型数据的比较

    在网上大题查了下这个问题,网上有的人说可以直接比较,并给出了测试用例,也有的人说不能比较,于是我自己尝试了一下,实际测试是可以的,不过,当传入DATA类型时间与DATATIME类型时间进行比较的时候, ...

  10. wlan相关查询命令

    1.查看当前连接的设备 hostapd_cli all_sta