原文链接: https://my.oschina.net/xiaocon/blog/199414
finally关键字的意思是只要异常,到最后都会执行语句块。。。
#
!/usr/bin/python
import
time
try
:
f
=file(
'
poem.txt
'
)
while
True:
line
=
f.readline()
if
len(line)==
0:
break
time.sleep(
2
)
print
line,
finally
:
f.close()
print
'
file.close
'
转载于:https://my.oschina.net/xiaocon/blog/199414