문서의 이전 판입니다!
# python 2.5 from __future__ import with_statement with open("hello.txt") as f: for line in f: print line # In older versions of Python, you would have needed to do this to get the same effect: f = open("hello.txt") try: for line in f: print line finally: f.close()