파이썬 파일 write() w1 파이썬 파일 쓰기 파이썬 기존의 파일에 쓰기 기존 파일에 쓰려면 open() 함수에 매개 변수를 추가해야 한다: "a" - 추가 - 파일 끝에 추가된다 "w" - Write - 기존 내용을 덮어쓴다 "exfile2.txt" 파일을 열고 파일에 내용을 추가한다: f = open("exfile2.txt", "a") f.write("Now the file has more content!") f.close() #open and read the file after the appending: f = open("exfile2.txt", "r") print(f.read()) 위의 코드를 실행하면 아래 그림과 같다. exfile3.txt 파일을 열고 내용을 덮어쓴다: f = open("exfile3.txt", "w") f.write("W.. 2023. 12. 1. 이전 1 다음