사용자 도구

사이트 도구


python:file

문서의 이전 판입니다!


Python File 다루기

파일 열어 줄 읽기

# 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()
python/file.1342494408.txt.gz · 마지막으로 수정됨: 2012/07/17 12:06 저자 kwon37xi