Python_29_ writelines( )

hyeong taek jo·2023년 9월 13일

Python

목록 보기
33/53

📌 writelines( )

  • 문자열을 담은 리스트의 내용을 파일에 쓰는 writelines()함수
  • 리스트(lines)에 저장된 내용을 읽어서 'movie_quotes.txt' 파일에 저장함.
lines = ["we'll find a way we always have - Interstellar\n",
         "I'll find you and I'll kill you - Taken\n",
         "한글  I'll be back - Terminator 2\n"]

with open('movie_quotes.txt','w',encoding='UTF8') as file:
    file.writelines(lines)

파일이 생김

profile
마포구 주민

0개의 댓글