파일 다루기


파일 다루기

파일 Handle 처리 방식 file = open(‘data.txt’) content = file.read() file.close() with open(‘data.txt’) as file: content = file.read() ※ with를 사용하면 file handle close에 대해서 신경쓸 필요 없음. 파이썬에서 알아서 close 함 contents = [] file = open(‘data.txt’) for line in file: contents = append(line) file.close contents = [] with open(‘data.txt’) as file: for line in file: contents.append(line)...

파일 다루기에 대한 요약내용입니다.

자세한 내용은 아래에 원문링크를 확인해주시기 바랍니다.



원문링크 : 파일 다루기