修改代码错误

next(iterator[, default])如果没有设置默认值,迭代结束的时候仍然会抛出StopIteration异常
This commit is contained in:
zhidong
2016-01-09 14:37:19 +08:00
parent 414614f5d0
commit 84719609ea

View File

@@ -32,7 +32,7 @@
with open('/etc/passwd') as f:
while True:
line = next(f)
line = next(f, None)
if line is None:
break
print(line, end='')