본문 바로가기
파이썬

파이썬 현재 txt를 덮어 쓰지 않고 파일에 파이썬 쓰기

by º기록 2020. 12. 20.
반응형
with open("games.txt", "w") as text_file:
    print(driver.current_url)
    text_file.write(driver.current_url + "\n")

지금이 코드를 사용하고 있지만 파일에 쓸 때 이전 콘텐츠를 덮어 씁니다. 이미있는 콘텐츠를 지우지 않고 어떻게 추가 할 수 있습니까?

 

해결 방법

 


with open("games.txt", "a") as text_file:

 

참조 페이지 https://stackoverflow.com/questions/22441803

 

 

반응형

댓글