python问题:IndentationError:expected an indented block
Python语言是一款对缩进非常敏感的语言,给很多初学者带来了困惑,即便是很有经验的Python程序员,也可能陷入陷阱当中。最常见的情况是tab和空格的混用会导致错误,或者缩进不对,而这是用肉眼无法分别的。
在编译时会出现这样的错IndentationError:expected an indented block说明此处需要缩进,你只要在出现错误的那一行,按空格或Tab(但不能混用)键缩进就行。
往往有的人会疑问:我根本就没缩进怎么还是错,不对,该缩进的地方就要缩进,不缩进反而会出错,,比如:
if xxxxxx:
(空格)xxxxx
或者
def xxxxxx:
(空格)xxxxx
还有
for xxxxxx:
(空格)xxxxx
一句话 有冒号的下一行往往要缩进,该缩进就缩进
python问题:IndentationError:expected an indented block的更多相关文章
- python中IndentationError: expected an indented block错误的解决方法
IndentationError: expected an indented block 翻译为IndentationError:预期的缩进块 解决方法:有冒号的下一行要缩进,该缩进就缩进
- python 出现indentationError:expected an indented block!
出现这个问题,代码一般是没问题的,剩下你要考虑: 1. 缩进对齐是否有问题 2. python脚本的格式是啥,如果你在linux上运行,编码需要是unix; (大部分情况下,我们是在windows下 ...
- [转]python问题:IndentationError:expected an indented block错误解决
分类: python学习笔记2012-07-07 17:59 28433人阅读 评论(4) 收藏 举报 python语言 原文地址:http://hi.baidu.com/delinx/item/17 ...
- python问题:IndentationError:expected an indented block错误解决《转》
python问题:IndentationError:expected an indented block错误解决 标签: python语言 2012-07-07 17:59 125145人阅读 评论( ...
- python问题:IndentationError:expected an indented block错误解决
Python语言是一款对缩进非常敏感的语言,给很多初学者带来了困惑,即便是很有经验的Python程序员,也可能陷入陷阱当中.最常见的情况是tab和空格的混用会导致错误,或者缩进不对,而这是用肉眼无法分 ...
- Python问题1:IndentationError:expected an indented block
Python语言是一款对缩进非常敏感的语言,给很多初学者带来了困惑,即便是很有经验的python程序员,也可能陷入陷阱当中.最常见的情况是tab和空格的混用会导致错误,或者缩进不对,而这是用肉眼无法分 ...
- python 中出现 “IndentationError: expected an indented block” 问题
python 学习 在定义Python函数的时候如下 >>>def hello() . . .print "hello" 这样会报错的,报错如下: Indenta ...
- IndentationError : expected an indented block
IndentationError:在python的条件语句出现 expected an indented block问题 是指缩进问题,比如for循环里面的print前面需要四个空格. Python语 ...
- IndentationError:expected an indented block错误解决
Python语言是一款对缩进非常敏感的语言,给很多初学者带来了困惑,即便是很有经验的Python程序员,也可能陷入陷阱当中.最常见的情况是tab和空格的混用会导致错误,或者缩进不对,而这是用肉眼无法分 ...
随机推荐
- .netCore部署在IIS上遇到的问题(500.19,500.21错误)
1.确保IIS功能都安装上了. 2.确保.netcore 的最新sdk已安装. 3.应用程序池改成无托管代码 4.500.19错误 错误原因,没有安装 DotNetCore.2.0.5-Windows ...
- 谁是狸猫谁是太子?--戏说java构造器
故事背景 <狸猫换太子>在我国民间文学中很出名,故事剧情大致如下:北宋第三位皇帝宋真宗赵恒年长无子,他的两个妃子刘妃与李妃同时怀了身孕.真宗召见二人,各赐信物,并声明哪个生了儿子就立谁为皇 ...
- Android Studio [Toast]
ToastActivity.java package com.xdw.a122; import android.support.v7.app.AppCompatActivity; import and ...
- Linux虚拟机--进入MySQL报错的解决办法
在Linux安装MySQL有时候会出现 [mysql]ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/ ...
- 小型APP系统开发与应用项目实训
实训项目 : 小型APP系统开发与应用项目实训 项目成品名称: 果乐多商城 项 ...
- setStyleSheet 设置背景图片
设置背景颜色很简单,大部分教程都对 设置背景图像有一个小坑. 设置背景图像主要有两种情况, 第一种:图片的绝对路径 ``` this->setObjectName("mainWindo ...
- Redis 集群(三)
为什么为有集群 在 Redis3 版本之前,每台 Redis 机器需要存储所有 Redis key ,这要求每台 Redis 机器有足够大的内存 而且只能是主节点写,从节点读,对于高并发情况下会有性能 ...
- Spring 梳理 - 开启并配置 Spring MVC 的方法
传统web.xm中配置两个上下文+两个context对应的xml+两个上下文bean分别手动配置 传统web.xm中配置两个上下文+两个context对应的xml+<mvc:annotation ...
- ViewModel 和 ViewModelProvider.Factory:ViewModel 的创建者
本文翻译自:https://medium.com/koderlabs/viewmodel-with-viewmodelprovider-factory-the-creator-of-viewmodel ...
- Spring Cloud Config 配置中心实践过程中,你需要了解这些细节!
本文导读: Spring Cloud Config 基本概念 Spring Cloud Config 客户端加载流程 Spring Cloud Config 基于消息总线配置 Spring Cloud ...