Notice
Recent Posts
Recent Comments
Link
목록TextFileHandling (1)
SeouliteLab
[Python/파이썬] Text 파일 읽고 쓰는 방법
Python에서는 텍스트 파일을 읽고 쓰는 기능을 제공합니다. 파일을 읽어오거나 쓰는 과정은 매우 중요하며, 이를 통해 데이터를 저장하고 처리할 수 있습니다. 이번에는 파일을 읽고 쓰는 세 가지 주요 작업에 대해 알아보겠습니다: read, write, append. 1. 파일 읽기 (read) file_path = "example.txt" with open(file_path, "r") as file: content = file.read() print(content) 2. 파일 쓰기 (write) file_path = "example.txt" with open(file_path, "w") as file: file.write("This is a sample text.\n") file.write("Writin..
프로그래밍
2024. 3. 1. 15:03