即使else语句与前面的if语句不一致,代码如何工作?
ret_code = -1
MAX_COUNT = 3
if ret_code < 0:
for i in range(MAX_COUNT-1):
print("sleep")
ret_code = 4
if ret_code >= 5:
break
else:
print(ret_code, '', 'Error')
输出如下:
Python 3.5.2 (default, Dec 2015, 13:05:11)
[GCC 4.8.2] on linux
sleep
sleep
4 Error
这是如何运作的?