입출력1 [python] 파일 입출력 기초 가이드 [Python] 파일 입출력 기초 가이드 파일 입출력은 프로그래밍의 기본이자 필수 요소다.Python에서 파일을 다루는 방법부터 실전에서 자주 사용하는 패턴까지 알아보자. 텍스트 파일 읽기/쓰기기본적인 파일 읽기# 전체 파일 읽기with open('example.txt', 'r', encoding='utf-8') as file: content = file.read() print(content)# 한 줄씩 읽기with open('example.txt', 'r', encoding='utf-8') as file: for line in file: print(line.strip()) # strip()으로 줄바꿈 제거# 모든 줄을 리스트로 읽기with open('example.txt'.. 2024. 11. 20. 이전 1 다음