比如在运行如下代码:

elif TempStr[-1] in['F','f']:
c = (eval(TempStr[0:-1])-32)/1.8print("{:.2f}C".format(c))

那么就会报如下的错误:

expected an indented block after 'elif' statement

这是为什么呢?什么又是indented block?

indented block 叫做代码块缩进

所谓缩进:

一行代码开始前的空白区域,表达程序的格式框架

严格明确 缩进是语法的一部分,缩进不正确程序运行错

缩进是表示所属关系,也是表达代码间包含和层次关系的唯一手段。

我们平时用得缩进只要是长度一致,在程序内一致即可,一般用4个空格或者TAB

python初学:expected an indented block 报错相关推荐

  1. expected an indented block报错的原因

    Python编写时报错:expected an indented block 因为Python中没有分号,用严格的缩进来表示上下级从属关系. 添加Tab缩进后不再报错!

  2. Python翻转字典,以及解决IndentationError: expected an indented block报错!

    1,Windows+R启动:运行 2,输入:cmd 回车打开! 3,输入python(假设你已经安装过了python) 里面还会出现版本号! 4,输入代码: 注意:如果空格缩进不对,会报错的! 比如: ...

  3. python 获取你电脑纯文本文档内容!解决IndentationError: expected an indented block报错!

    1,Windows+R启动:运行 2,输入:cmd 回车打开! 3,输入python(假设你已经安装过了python) 里面还会出现版本号! 4,输入代码: 注意:如果空格缩进不对,会报错的! 比如: ...

  4. Python中expected an indented block

    Python严格地要求代码缩进,缩进的代码块相对于上一级是从属关系.用if语句举个例子: if a==2: print 'hello world'if语句的条件为真时会执行print语句,print语 ...

  5. Python : IndentationError: expected an indented block

    如下图 运行包报错: IndentationError: expected an indented block 处理方法是 问题原因 1冒号后面要跟要写一些内容的, 2 其他位置,或多或少空格的位置不 ...

  6. python 报错 IndentationError: expected an indented block SyntaxError: invalid character in identifie

    红色方框那里敲击一个空格就好! 输入要在全英情况下! 另外,还要注意括号的事情.括号别出错误! IndentationError: expected an indented block的报错: Syn ...

  7. Python报错“IndentationError: expected an indented block“

    问题描述: 一段python代码中使用了if name == 'main':,运行程序是报错"IndentationError: expected an indented block&quo ...

  8. python 报错:IndentationError: expected an indented block

    def get_formatted_name_0(first_name,last_name,middle_name=''):"""返回整洁的姓名""& ...

  9. Python报错:IndentationError: expected an indented block

    IndentationError: expected an indented block 直译为:缩进错误:需要缩进的块 在Python中,函数间的判定归属由缩进的块来决定而不是一组组括号 出现这个错 ...

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

    原文地址  http://blog.csdn.net/neilhappy/article/details/7724959 Python语言是一款对缩进非常敏感的语言,给很多初学者带来了困惑,即便是很有 ...

最新文章

  1. HttpURLConnection IllegalStateException
  2. 用神经集认识手写数字
  3. Electron 调用系统工具记事本、计算器等
  4. EPON与GPON的应用与区别
  5. javascript 入门事件的
  6. 从介质部署额外域控制器
  7. 堆垛管理,下料管理系统
  8. rhel4 x86_64 php5.2.17 make安装 支持mysqli
  9. 用cxf公布和调用web service
  10. jQuery构建路由
  11. VirtualBox虚拟机,WIN7的性能远远落后于LINUX及解决办法
  12. zmap扫描mysql_互联网扫描器 ZMap 完全手册
  13. 开源文档协作套件CryptPad
  14. (六十五)Android O StartService的 anr timeout 流程分析
  15. sa6155p以太网卡驱动emac-dwc-eqos
  16. excel 使用技巧小总结
  17. 【图像去噪】基于非局部均值(NLM)滤波图像去噪matlab源码
  18. github上面fork代码如何提交分支合并申请
  19. DR/BDR选举过程及作用详解
  20. k8s重启导致node没有成功连接:The connection to the server localhost:8080 was refused - did you specify the righ

热门文章

  1. 【更新于2019】SCI EI 索引最新查询方法(已验证有效)
  2. php短信验证码随机数_深入解读PHP短信验证码原理
  3. 【单例模式、多例模式、工厂模式和枚举】
  4. 使用axure rp8 制作一个iphonex手机框架
  5. 属性值第二个字符是大写引发的血案Warning:(X,X) java: Unmapped target property: “vCpu“.
  6. 团队作业九---项目验收与总结
  7. 佛系程序员之歌 - 和我一起减减压
  8. C++ 输入输出加速挂(ACM竞赛常用)
  9. linux日志删除了还能恢复吗,Linux系统中恢复被删除日志的方法
  10. c语言字符串拼接变量,C语言实现字符串拼接