IT 기본 (9) 썸네일형 리스트형 python에서 with문 사용목적 파일 입출력 후 close를 항상 해주어야 하지만, with 사용시에 close를 하지 않아도 되는 이점이 있다. 파일 입출력 f = open('test.txt', 'r') print(f.readline()) f.close() with을 사용해 파일 입출력 f = open('test.txt', 'r') with f as in_file: print(in_file.readlines()) 또는 with open('test.txt', 'r') as in_file: print(in_file.readlines()) 이전 1 2 다음