2010年4月25日 星期日

Python - with語法

The with statement creates what’s called a context: when the with block ends, Python will automatically close the file, even if an exception is raised inside the with block. You’ll learn more about with blocks and file objects in the Files chapter.


with 類似於 C#裡的using用法
會自動關閉 open()