PYTHON

[python basic] file 쓰기

하이하이2222 2023. 11. 21. 08:11

open(‘sample.txt’, ’w’) as f
w는 write의 약자로 파일을 쓸때

f.write(“hello world\n”)

open(‘sample.txt’, ’a’) as f

a는 append로 파일 내용에 추가
파일이 없다면 생성