IndentationError 是否是 Python 中的语法错误? [英] Is IndentationError a syntax error in Python or not?

查看:18
本文介绍了IndentationError 是否是 Python 中的语法错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的问题,

IndentationError 是否是 Python 中的 SyntaxError?

Is IndentationError a SyntaxError in Python or not?

我认为不是,但由于我是初学者,我想确定一下.语法错误只是那些给我 SyntaxError 作为解释器响应的错误吗?例如,如果我输入

I think it is not but since I am a beginner I would like to be sure. Are syntax errors only those which give me SyntaxError as a response in an interpreter? For example, if I type

3f = 22 

我明白了

SyntaxError: invalid syntax 

所以如果还有其他的东西(IndentationError 等),它可能是 SyntaxError 的子类型吗?

So if there's something else (IndentationError etc), may it be a sub-type of SyntaxError or not?

推荐答案

>>> issubclass(IndentationError, SyntaxError)
True

是的意思

更多信息这里这里

这篇关于IndentationError 是否是 Python 中的语法错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆