为什么这个工程:Python懒惰布尔评价出错了?
s = 'xyz'
i = 0
while i < len(s) and s[i] not in 'aeiou':
print(s[i])
i += 1
x y z
...但是这不?
s = 'xyz'
i = 0
while s[i] not in 'aeiou' and i < len(s):
print(s[i])
i += 1
x y z Traceback (most recent call last): File "<pyshell#135>", line 1, in <module> while s[i] not in 'aeiou' and i <= len(s): IndexError: string index out of range
我很困惑,我缺少什么吗?
在'我[i]不在'aeiou'和我
2013-09-26 05:54:52
实际上标题应该是“懒惰的评估工作,如预期和记录一样。 – Hyperboreus