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

本文转载于:http://blog.csdn.net/sinat_36384705/article/details/71155379

首先这个错误的意思是:在缩进的时候,使用了错误的空格和tab

我使用的python3.5,造成这个错误的原因是我在函数里面敲if....elif 判断语句的时候,elif之前先用了空格然后再用tab完成了对齐,也就是说,这种错误产生的原因正是由于空格或者tab缩进造成的。

然后我做了试验,将空格删除,直接使用tab完成缩进,发现程序正常运行;

再试一下空格缩进,然后发现还是报错了,同样TabError: Inconsistent use of tabs and spaces in indentation。

 

也就是说,python3.5是要用tab完成缩进的,而且不能使用空格,否则会报错

原文地址:https://www.cnblogs.com/curo0119/p/8428829.html

时间: 2024-08-11 21:06:45

python运行错误---TabError: Inconsistent use of tabs and spaces in indentation的相关文章

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

1. 问题描述 2. 问题原因 tab 和 space混合使用导致程序错误 3. 解决方案 排查出错地方的格式 原文地址:https://www.cnblogs.com/HurryXin/p/9461391.html

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

在遍历打印10以内的奇数是出现"TabError: inconsistent use of tabs and spaces in indentation"的错误提示: 代码如下: 第一感觉没什么错误,但是当我设置显示"空格与制表符"时候,问题出现了,在第4.5行前由制表符,如图所示: 在if和continue前有制表符,所以执行的时候会提示"TabError: inconsistent use of tabs and spaces in indentati

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 这是我的代码,感觉没啥不对, 后来运行之后出现了下面的错误,我也是弄了好久才弄好这个bug. . 这个一般是由于你用编译器写代码时的Tab符和空格符混用引起的.对于Notepade++来说,只要你设置"显示空格和制表符"就行. 1.点击如下按钮: 2.手动设置: View->Show Symbl->Show All Characters 下面是设置之

TabError: Inconsistent use of tabs and spaces in indentation

Pyhton 编辑错误 问题: TabError: Inconsistent use of tabs and spaces in indentation 解决方法: 这个错误是说你用了tab键作缩进了, 因为在python不像C/C++里用大括号来区分程序块,而是用缩进 所以缩进很重要你把Tab都换成空格就好了 版权声明:本文为博主原创文章,未经博主允许不得转载.

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

本文使用PyCharm的格式化代码功能解决TabError: inconsistent use of tabs and spaces in indentation. 当把代码从别处复制进来PyCharm,然后运行报错:TabError: inconsistent use of tabs and spaces in indentation 这个报错的意思是说IDE分不清tab和空格,说明你的代码中混用了tab和空格. 传统的方式是找出代码中报错的地方,然后修改. 这种方法可以,但是我试的并不好用.

python运行错误------Non-UTF-8 code

1.安装-----见:https://www.cnblogs.com/weven/p/7252917.html 本文转载于:http://blog.csdn.net/youyuyixiu/article/details/52886692 当python中的代码有中文时,有时会出现下图错误. 解决方法就是在程序的第一行加上 #coding=gbk 1 这样程序就正确啦,如下图. 原文地址:https://www.cnblogs.com/curo0119/p/8428807.html

Python脚本运行出现语法错误:IndentationError: unindent does not match any outer indentation level(转)

[问题] 一个python脚本,本来都运行好好的,然后写了几行代码,而且也都确保每行都对齐了,但是运行的时候,却出现语法错误: IndentationError: unindent does not match any outer indentation level [解决过程] 1.对于此错误,最常见的原因是,的确没有对齐.但是我根据错误提示的行数,去代码中看了下,没啥问题啊. 都是用TAB键,对齐好了的,没有不对齐的行数啊. 2.以为是前面的注释的内容影响后面的语句的语法了,所以把前面的注释

Python脚本运行出现语法错误:IndentationError: unindent does not match any outer indentation level

[问题] 一个python脚本,本来都运行好好的,然后写了几行代码,而且也都确保每行都对齐了,但是运行的时候,却出现语法错误: IndentationError: unindent does not match any outer indentation level [解决过程] 1.对于此错误,最常见的原因是,的确没有对齐.但是我根据错误提示的行数,去代码中看了下,没啥问题啊. 都是用TAB键,对齐好了的,没有不对齐的行数啊. 2.以为是前面的注释的内容影响后面的语句的语法了,所以把前面的注释

Python脚本运行出现语法错误:IndentationError: unindent does not match any outer indentation level【转】

http://www.crifan.com/python_syntax_error_indentationerror/ [问题] 一个python脚本,本来都运行好好的,然后写了几行代码,而且也都确保每行都对齐了,但是运行的时候,却出现语法错误: IndentationError: unindent does not match any outer indentation level [解决过程] 1.对于此错误,最常见的原因是,的确没有对齐.但是我根据错误提示的行数,去代码中看了下,没啥问题啊