728x90 반응형 SMALL 파일 존재 확인1 [Python] 파일 위치 이동 및 확인 (2) with 문을 사용한 파일 관리 with 문을 사용하여 파일을 열고 내용을 읽은 다음 출력한다. with open('example.txt', 'r') as file_object: content = file_object.read() print(content) 파일에 여러 줄 쓰기 파이썬 코드를 작성하여 여러 줄을 포함하는 문자열을 텍스트 파일에 쓴다. # 파일 열기 file_object = open('multiline_example.txt', 'w') # 여러 줄의 문자열 content = """This is a multiline string. Python is a versatile language. It is easy to learn and use.""" # 파일에 내용 쓰기 file_object.wri.. 2023. 6. 20. 이전 1 다음 728x90 반응형 LIST