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”问题的解决
随机推荐
- Core项目部署到IIS上delete、put谓词不支持
解决方法:在web.config的system.webServer结点下添加如下代码 <modules runAllManagedModulesForAllRequests="true ...
- vue 父子组件数据的双向绑定大法
官方文档说明 所有的 prop 都使得其父子 prop 之间形成了一个 单向下行绑定 父级 prop 的更新会向下流动到子组件中,但是反过来则不行 2.3.0+ 新增 .sync 修饰符 以 upda ...
- ef core many to many
https://stackoverflow.com/questions/46184678/fluent-api-many-to-many-in-entity-framework-core/461847 ...
- TVM图优化(以Op Fusion为例)
首先给出一个TVM 相关的介绍,这个是Tianqi Chen演讲在OSDI18上用的PPThttps://files.cnblogs.com/files/jourluohua/Tianqi-Chen- ...
- Spring7大模块
Spring 框架是一个分层架构,由 7 个定义良好的模块组成.Spring 模块构建在核心容器之上,核心容器定义了创建.配置和管理 bean 的方式,组成 Spring 框架的每个模块(或组件)都可 ...
- 4.SpringMVC 配置式开发-处理器映射器
处理器映射器 HandlerMapping HandlerMapping 接口负责根据request请求找到对应的Handler处理器及Interceptor拦截器, 并将它们封装在HandlerEx ...
- JDK 安装部署
环境: OS: CentOS 6.4 JDK版本: jdk-7u17-linux-x64.tar.gz 一.解压JDK程序包: # tar -xf jdk-7u17-linux-x64.tar.gz ...
- Python3+Appium学习笔记04-自动下载apk
在项目中,app更新后,都会发布新的apk版本,然后去蒲公英对应的网站上扫码下载对应的apk进行测试.所以就在想,通过app参数进行安装时,是否可以先通过代码去拉取一遍最新的apk安装包. 因为学 ...
- python豆知识: for和while的else语句。
for语句,当可迭代对象耗尽后执行else语句. while循环,当条件为False后执行else. a = 1 while a != 10: a += 1 else: print(a)
- P5074 Eat the Trees
思路 同样是插头DP,但是这题因为可以形成多个回路,所以左右括号是没有区别的,只需要01就可以表示了 注意if的嵌套关系 注意全零矩阵也要输出1 代码 #include <cstdio> ...