本文介绍了Python缩进语义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只是有一个非常简单的问题,只需要确认我明白了。
I just have a very simple question, and just need to confirm that I got the point.
假设我们有以下Python代码片段:
Say that we have the following Python code snippet:
x = 0
if x == 5:
print 'x is equal to 5'
else:
print 'x is not equal to 5'
print 'program done'
如果我们将语句打印'程序完成'
缩进如下:
If we indent the statement print 'program done'
as follows:
else:
print 'x is not equal to 5'
print 'program done'
将打印'程序完成'
在这种情况下是与 else ?
推荐答案
来自:
所以,是的,它将属于
else
阻止。
So, yeah, it will belong to the
else
block.
这篇关于Python缩进语义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!