Python语言是一款对缩进非常敏感的语言,给很多初学者带来了困惑,即便是很有经验的Python程序员,也可能陷入陷阱当中。最常见的情况是tab和空格的混用会导致错误,或者缩进不对,而这是用肉眼无法分别的。

在编译时会出现这样的错IndentationError:expected an indented block说明此处需要缩进,你只要在出现错误的那一行,按空格或Tab(但不能混用)键缩进就行。

往往有的人会疑问:我根本就没缩进怎么还是错,不对,该缩进的地方就要缩进,不缩进反而会出错,,比如:

if xxxxxx:

(空格)xxxxx

或者

def xxxxxx:

(空格)xxxxx

还有

for xxxxxx:

(空格)xxxxx

一句话 有冒号的下一行往往要缩进,该缩进就缩进

IndentationError:expected an indented block错误解决的更多相关文章

  1. python问题:IndentationError:expected an indented block错误解决《转》

    python问题:IndentationError:expected an indented block错误解决 标签: python语言 2012-07-07 17:59 125145人阅读 评论( ...

  2. [转]python问题:IndentationError:expected an indented block错误解决

    分类: python学习笔记2012-07-07 17:59 28433人阅读 评论(4) 收藏 举报 python语言 原文地址:http://hi.baidu.com/delinx/item/17 ...

  3. python问题:IndentationError:expected an indented block错误解决

    Python语言是一款对缩进非常敏感的语言,给很多初学者带来了困惑,即便是很有经验的Python程序员,也可能陷入陷阱当中.最常见的情况是tab和空格的混用会导致错误,或者缩进不对,而这是用肉眼无法分 ...

  4. python中IndentationError: expected an indented block错误的解决方法

    IndentationError: expected an indented block 翻译为IndentationError:预期的缩进块 解决方法:有冒号的下一行要缩进,该缩进就缩进

  5. IndentationError: expected an indented block错误

    Python语言是一款对缩进非常敏感的语言,给很多初学者带来了困惑,即便是很有经验的python程序员,也可能陷入陷阱当中.最常见的情况是tab和空格的混用会导致错误,或者缩进不对,而这是用肉眼无法分 ...

  6. IndentationError : expected an indented block

    IndentationError:在python的条件语句出现 expected an indented block问题 是指缩进问题,比如for循环里面的print前面需要四个空格. Python语 ...

  7. Python问题1:IndentationError:expected an indented block

    Python语言是一款对缩进非常敏感的语言,给很多初学者带来了困惑,即便是很有经验的python程序员,也可能陷入陷阱当中.最常见的情况是tab和空格的混用会导致错误,或者缩进不对,而这是用肉眼无法分 ...

  8. python问题:IndentationError:expected an indented block

    Python语言是一款对缩进非常敏感的语言,给很多初学者带来了困惑,即便是很有经验的Python程序员,也可能陷入陷阱当中.最常见的情况是tab和空格的混用会导致错误,或者缩进不对,而这是用肉眼无法分 ...

  9. python 中出现 “IndentationError: expected an indented block” 问题

    python 学习 在定义Python函数的时候如下 >>>def hello() . . .print "hello" 这样会报错的,报错如下: Indenta ...

随机推荐

  1. MySQL连接java

    1.创建一个java project,建一个lib文件. 下载MySQL-connecor. 将下载好的文件打开,将mysql-connector-java-5.0.8-bin.jar文件粘贴复制到l ...

  2. Caffarelli 关于自由边界正则性的论文C1

    Caffarelli 关于自由边界正则性的论文 接下来主要想叙述一下Caffarelli的C1文章中的一些想法,这是最近这几天看的文献. 对于从自由边界的Lipschitz正则性到$C^{1,\alp ...

  3. 『TensorFlow』读书笔记_Inception_V3_下

    极为庞大的网络结构,不过下一节的ResNet也不小 线性的组成,结构大体如下: 常规卷积部分->Inception模块组1->Inception模块组2->Inception模块组3 ...

  4. pytoch word_language_model 代码阅读

    参考代码地址:https://github.com/pytorch/examples/tree/master/word_language_model /word_language_model/data ...

  5. 【C/C++】Rotate Array

    实现数组旋转(循环右移) 如数组 [1, 2, 3, 4, 5, 6, 7],右移 3 位则为 [5, 6, 7, 1, 2, 3, 4] 首先使用泛型函数 void Rotate(void *fro ...

  6. input输入框只能输入正整数

    <input type="text" value="1" onkeyup="if(this.value.length==1){this.valu ...

  7. js实现数组去重

    1.遍历 let aArray = [1,2,2,3,3,"3"] let bArray = [] for(const a of aArray){ let index = bArr ...

  8. C++解析九-数据抽象

    数据抽象 数据抽象是指,只向外界提供关键信息,并隐藏其后台的实现细节,即只表现必要的信息而不呈现细节.数据抽象是一种依赖于接口和实现分离的编程(设计)技术.让我们举一个现实生活中的真实例子,比如一台电 ...

  9. Java基础-常用工具类(二)

    Scanner 类 java.util.Scanner 是 Java5 的新特征,我们可以通过 Scanner 类来获取用户的输入. 通过 Scanner 类的 next() 与 nextLine() ...

  10. python IDE PyCharm的安装

    首先去Pycharm官网,或者直接输入网址:http://www.jetbrains.com/pycharm/download  : 选择Windows系统 免费版本下载: 双击下载的安装包,进行安装 ...