«   2026/09   »
일 월 화 수 목 금 토
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
Archives
Today
Total
«   2026/09   »
일 월 화 수 목 금 토
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
Archives
Today
Total
관리 메뉴

DBILITY

python archive file 다루기 본문

python

python archive file 다루기

DBILITY 2021. 8. 12. 12:49
반응형

binary는 mode에 b가 추가 됨

# archive write mode
f = open('a.txt', encoding='utf-8', mode='w')
f.write('나 --> 언제 왔냐?\n')
f.write('너 --> 쪼끔 전에 왔다.\n')
f.close()

# archive append mode
f = open('a.txt', encoding='utf-8', mode='a')
f.write('나 --> 뭐하러 왔냐?\n')
f.write('너 --> 내비~족구화! 길을 잘못 들어서..\n')
f.write('나 --> 머더뻐꾹!\n')
f.close()

# archive read mode
f = open('a.txt', encoding='utf-8', mode='r')
w=f.read()
print(w)
f.close()

나 --> 언제 왔냐?
너 --> 쪼끔 전에 왔다.
나 --> 뭐하러 왔냐?
너 --> 내비~족구화! 길을 잘못 들어서..
나 --> 머더뻐꾹!

반응형
Comments