파이썬 : file input output
2020. 10. 15.
파이썬 : 파일 객체 다루기 open 내장 함수의 문서를 보면 아래와 같이 되어있다. open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) 여기서는 기본적인 파일을 다루는 법과 mode 를 살펴본다. 먼저 같은 path (해당 스크립트와 같은 path) 에 score.txt 파일을 하나 만든다. 내용은 아래와 같다. 수학: 0 영어: 10 과학 : 80 국어 : 30 ===파일 읽기 score_file = open("score.txt", "r") # score_file # 불러온 파일 객체 score_file.read() # 파일의 내용물 score_file.close() ..