Python入門的36個例子 之 36 -> finally

 

output:

 

>>>
# 040

import time

try:
    f = file('040_Finally.py')
    while True:
        line = f.readline()
        if len(line) == 0:
            break
        time.sleep(0.33)
        print line,
    # end of while
finally:
    f.close()
    print 'Closed the file.'
# end of try
   
Closed the file.
>>>

源代碼下載:下載地址在這裏

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章