Python_30_ readlines()

hyeong taek jo·2023년 9월 13일

Python

목록 보기
34/53

📌 readlines()

  • 'movie_quotes.txt' 파일의 내용을 줄 단위로 한꺼번에 읽어오는 readlines()함수
  • 자원 해제 다른 프로그램이 접근 할수 있도록 With 문 끝날때 자동 Close

📌 예시

with open('movie_quotes.txt', 'r', encoding='UTF8') as file:
    lines = file.readlines()
    line = ''

    for line in lines:
        print(line,end='')

we'll find a way we always have - Interstellar
I'll find you and I'll kill you - Taken
한글 I'll be back - Terminator 2

profile
마포구 주민

0개의 댓글