[python] txt 작업

최승언·2023년 1월 8일
0

python

목록 보기
12/22

텍스트 파일 쓰기 예제

f = open(path, "w", encoding='utf-8-sig')
f.write('text'+'\n')
f.close()

텍스트 파일 읽기 예제

with open(path, 'rt', encoding='utf-8-sig') as f:
    while True:
        text = f.readline()
        if not text:
            break
profile
작업하다가 막힌부분을 기록하는 곳.

0개의 댓글