vscode 遇到 TabError: inconsistent use of tabs and spaces in indentation
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的更多相关文章
- 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 ...
- PyCharm出现TabError: inconsistent use of tabs and spaces in indentation最简单实用的解决办法
本文使用PyCharm的格式化代码功能解决TabError: inconsistent use of tabs and spaces in indentation. 当把代码从别处复制进来PyChar ...
- python 报错 TabError: inconsistent use of tabs and spaces in indentation
写python的时候如果出现如题的错误 TabError: inconsistent use of tabs and spaces in indentation 意为:制表符错误:缩进中制表符和空格使 ...
- 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 这是我的代码,感觉没啥不对, 后来运行之后出现了下面的错误,我也是弄了好久 ...
- python运行错误---TabError: Inconsistent use of tabs and spaces in indentation
本文转载于:http://blog.csdn.net/sinat_36384705/article/details/71155379 首先这个错误的意思是:在缩进的时候,使用了错误的空格和tab 我使 ...
- Python程序调试-TabError: inconsistent use of tabs and spaces in indentation
报错信息:TabError: inconsistent use of tabs and spaces in indentation 说明:代码缩进统一使用Tab键或空格键,不能混用. 解决办法: 1. ...
- Python文件运行时报TabError: inconsistent use of tabs and spaces in indentation
1. 问题描述 Python文件运行时报TabError: inconsistent use of tabs and spaces in indentation 2. 问题原因 tab 和 space ...
- python错误提示“TabError: inconsistent use of tabs and spaces in indentation”
在遍历打印10以内的奇数是出现“TabError: inconsistent use of tabs and spaces in indentation”的错误提示: 代码如下: 第一感觉没什么错误, ...
- Python中出现“TabError: inconsistent use of tabs and spaces in indentation”问题的解决
随机推荐
- windows服务与log4net应用
有时候我们需要用到window服务来执行定时任务,然后配合log4net记录程序运行情况,这里简单记录下配置的整个过程以及注意要点: 一.添加windows服务 1.设计页面,右键添加安装程序
- 【原创】大叔经验分享(80)openresty(nginx+lua)发邮件
nginx配置 lua_package_path "/usr/local/openresty/lualib/resty/smtp/?.lua;;"; lua_need_reques ...
- 基于PROMISE解决回调地狱问题
回调地狱问题: 在使用JavaScript时,为了实现某些逻辑经常会写出层层嵌套的回调函数,如果嵌套过多,会极大影响代码可读性和逻辑,这种情况也被成为回调地狱.比如说你要把一个函数 A 作为回调函数, ...
- Python中,标识符用法
Python中,标识符 在Python中,所有标识符都可以包括英文.数字和下划线(),但不能包括数字.python中的标识符区分大小写.这是知识的背景.但通常,Python成为以下划线开头的标识符的习 ...
- 小程序e.currentTarget与e.target 两个属性的区别
注册事件是获取小程序组件上面的自定义属性值 e.target是获取当前点击的标签上面的自定义属性 e.currentTarget是获取注册点击事件标签内的自定义属性
- Java秒杀实战 (三)秒杀基本功能开发
转自:https://blog.csdn.net/qq_41305266/article/details/80991687 一.两次MD5 1. 用户端: PASS = MD5( 明文 + 固定 Sa ...
- ADF简单介绍
1.ADF也是用的MVC的分层模式,如下图所示 2.Model层代理数据服务将数据关联在View层,用户则是在View层的UI界面上的操作来更改Model层代理的数据,Controller控制层执行用 ...
- 【atcoder】Enclosed Points [abc136F]
题目传送门:https://atcoder.jp/contests/abc136/tasks/abc136_f 题目大意:在平面上有$n$个点我们,定义一个点集的权值为平面上包含这个点集的最小矩形所包 ...
- 第五章、Django之模型层----多表查询
目录 第五章.Django之模型层----多表查询 一.一对多字段增删改查 1.增 2.查 3.改 4. 删除 二.多对多的增删改查 1. 增 2. 改 3. 删 三.ORM跨表查询 四.正反向的概念 ...
- OpenCV_contrib里的Text(自然场景图像中的文本检测与识别)
平台:win10 x64 +VS 2015专业版 +opencv-3.x.+CMake 待解决!!!Issue说明:最近做一些字符识别的事情,想试一下opencv_contrib里的Text(自然场景 ...