Python 缩进错误 Python IndentationError: expected an indented block

这是编写一个比大小方法时遇到的低级错误
这个错误的原因是if语句块缩进问题

原代码

def MAX(a,b):if(a > b):return aelse:return b;

错误提示

IndentationError: expected an indented block
# 缩进错误 : 应该为缩进块

这个很多相同错误都是一样的比如方法块的缩进错误、类的缩进错误等等,都是只需要按照Python语法标准缩进即可,还有就是不需要缩进的地方错误缩进。
按TAB缩进,比如在冒号之后的语法都是需要缩进的在Python3语法中。

def MAX(a,b):if(a > b):return aelse:return b
# return a if a > b else b

示例代码
PyCharm

def MAX(a,b):if(a > b):return aelse:return b
# return a if a  > b else bif __name__ == "__main__":print(MAX(1,4))print(MAX(6,4))

Python IndentationError: expected an indented block相关推荐

  1. Python : IndentationError: expected an indented block

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

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

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

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

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

  4. 成功解决python中出现的IndentationError: expected an indented block的错误

    成功解决python中出现的IndentationError: expected an indented block的错误 目录 解决问题 解决思路 解决方法 解决问题 当在python中出现这个错误 ...

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

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

  6. python出现expected an_Python错误:IndentationError:expected an indented block怎么解决

    出现 IndentationError:expected an indented block 错误 一般是因为缩进问题引起的. 实例分析: 错误代码: >>> for key in ...

  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. IndentationError:expected an indented block错误解决

    IndentationError:expected an indented block错误解决 描述: 有时一个简单的问题会困扰很久,当发现问题后才感觉自己是多蠢,下面记录一个在日常Python编程过 ...

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

    这样的错IndentationError:expected an indented block说明此处需要缩进,你只要在出现错误的那一行,按空格或Tab(但不能混用)键缩进就行. 有冒号的下一行往往要 ...

最新文章

  1. layui列表显示缩略图_layUI实现列表查询功能
  2. build.gradle里dependencies标签页的实现原理
  3. inner join 和join的区别_left join、right join和join ???
  4. Unity 3D开发-C#脚本语言的一些基础用法
  5. [转] 字符编码笔记:ASCII,Unicode和UTF-8
  6. 基于TCP的网络聊天系统
  7. Nmap命令:-sP和-sN的区别
  8. 武汉php的工资是多少钱,在武汉工作,月薪5000元属于什么水平?
  9. 视频素材-高质量缥缈雾气雾霾特效合成动画 Lens Distortions – Fog II
  10. 洛谷 P2440 木材加工
  11. 冷山的博客思听书摘索引页
  12. 传智播客风清扬视频-------IO简述之File讲解
  13. Vue 短信验证码组件
  14. 边缘计算卸载论文翻译于分析总结
  15. canvas教程6-绘制圆弧
  16. 如何利用在线帮助中心解决客户问题?
  17. 23年 yolov5车辆识别+行人识别+车牌识别+车速检测代码(python)
  18. 计算机系统保护怎么打开,如何开启系统还原 开启系统还原方法有哪些
  19. python中的多任务-多线程和多进程
  20. Hotspot 垃圾回收之ReferenceProcessor(二) 源码解析

热门文章

  1. OpenWrt自定义luci页面来修改配置文件
  2. [wpa_supplicant]基于ubuntu的wpa_supplicant工具的安装与使用
  3. JAVA 通过Excel导出pdf_教你用Java 将Excel转为PDF
  4. UG8.5中nxopen.dll等文件所在位置
  5. 手把手教你用 Keras 实现 LSTM 预测英语单词发音
  6. 使用HTML制作在线电子时钟,用HTML5制作数字时钟的教程
  7. java a的2次方_java-获取比a大,最接近a的2的次方的数(最小二次幂,位运算)
  8. 丹东dns服务器位置,各省主要DNS服务器对照表
  9. cif t t操作流程图_cif流程(cif贸易术语流程图)
  10. 设有如下定义:char *aa[ ]={abcd,ABCD };则以下说法正确的是 A aa 数组成元素的值分别是abcd和ABCD B aa是指针变量,它指向含有两个数组元