OS (1) 썸네일형 리스트형 [09] File Handling file_handling¶ 파이썬은 파일 처리를 위해 "open" 키워드를 사용한다. f = open("", "") f.close() r 읽기모드 - 파일을 읽기만 할 때 w 쓰기모드 - 파일에 내용을 쓸 때 a 추가모드 - 파일의 마지막에 새로운 내용을 추가 할 때 read() - txt파일 안에 있는 내용을 문자열로 반환¶ f = open("i_have_a_dream.txt", "r" ) contents = f.read() print(contents) f.close() with 구문과 함께 사용하기¶ with open("i_have_a_dream.txt", "r") as my_file: contents = my_file.read() print (type(contents), contents) 여러가지 .. 이전 1 다음