Python学习:IndentationError: expected an indented block
错误原因翻译过来是“缩进错误”。
python语言对缩进有严格的要求和控制,在编写代码时稍不注意就会出现缩进错误,导致编译运行出现IndentationError: expected an indented block这样的报错提示。
解决办法就是返回出错代码行查看缩进,这个时候要注意对照上下文查看,错误的原因也有可能不是该行缩进有问题,比如我的代码:
本身该行缩进是没问题的,但是受上文函数模块的影响,它就提示此处应有缩进。找到原因之后,我给函数添加一个pass返回值就解决了。
总言而之就是,在编写的过程中一定要仔细仔细再仔细!对python缩进这一难题,我愿称之为“娇气的小公举”。
Python学习:IndentationError: expected an indented block相关推荐
- python 报错 IndentationError: expected an indented block SyntaxError: invalid character in identifie
红色方框那里敲击一个空格就好! 输入要在全英情况下! 另外,还要注意括号的事情.括号别出错误! IndentationError: expected an indented block的报错: Syn ...
- python问题:IndentationError:expected an indented block错误解决
原文地址 http://blog.csdn.net/neilhappy/article/details/7724959 Python语言是一款对缩进非常敏感的语言,给很多初学者带来了困惑,即便是很有 ...
- 成功解决python中出现的IndentationError: expected an indented block的错误
成功解决python中出现的IndentationError: expected an indented block的错误 目录 解决问题 解决思路 解决方法 解决问题 当在python中出现这个错误 ...
- Python报错:IndentationError: expected an indented block
IndentationError: expected an indented block 直译为:缩进错误:需要缩进的块 在Python中,函数间的判定归属由缩进的块来决定而不是一组组括号 出现这个错 ...
- python出现expected an_Python错误:IndentationError:expected an indented block怎么解决
出现 IndentationError:expected an indented block 错误 一般是因为缩进问题引起的. 实例分析: 错误代码: >>> for key in ...
- python 报错:IndentationError: expected an indented block
def get_formatted_name_0(first_name,last_name,middle_name=''):"""返回整洁的姓名""& ...
- Python报错“IndentationError: expected an indented block“
问题描述: 一段python代码中使用了if name == 'main':,运行程序是报错"IndentationError: expected an indented block&quo ...
- Python : IndentationError: expected an indented block
如下图 运行包报错: IndentationError: expected an indented block 处理方法是 问题原因 1冒号后面要跟要写一些内容的, 2 其他位置,或多或少空格的位置不 ...
- IndentationError:expected an indented block错误解决
IndentationError:expected an indented block错误解决 描述: 有时一个简单的问题会困扰很久,当发现问题后才感觉自己是多蠢,下面记录一个在日常Python编程过 ...
- 解决错误:IndentationError:expected an indented block
这样的错IndentationError:expected an indented block说明此处需要缩进,你只要在出现错误的那一行,按空格或Tab(但不能混用)键缩进就行. 有冒号的下一行往往要 ...
最新文章
- 好书推荐:《零基础快速入行入职软件测试工程师》学测试一本就
- Java常用实体类--System类
- java element 属性_属性'value'在'HTMLElement'类型的值上不存在
- 语言学生学籍管理系统流程图_基于C语言的学生管理系统(含文件)(一)
- database disk image is malformed 问题解决
- 从1.5k到18k, 一个程序员的5年成长之路(分享)
- 代码,绘画,设计常用的颜色名称-16进制HEX编码-RGB编码 对照一览表
- csdn2020年度博客之星 - 直播间(恭喜圆满结束)
- 2020年墨天轮数据报告发布!
- [SDOI2007] 单词接龙游戏 dp
- @hotmail.com 账户添加别名,重命名到@outlook.com 一系列问题,顺道附上个人解决方法
- L1-046 整除光棍 (20 分)—团体程序设计天梯赛
- 【数据分析】基于matlab GUI学生成绩查询系统【含Matlab源码 604期】
- 太阳直射点纬度计算公式_高中地理——每日精讲1题(地震、太阳高度角、极昼、昼夜长短)...
- Ogre – 材质脚本(三) (转)
- YUV图像格式转换方法实践
- linux最好用的ftp服务器软件,Linux平台下快速搭建FTP服务器
- 【Linux】终端 [root@localhost ~]# 变成 -bash-4.2# 问题及解决
- thinkphp使用phpqrcode类生成二维码
- element-plus日历(Calendar)动态渲染+避坑指南