Python open().read()
사용 버전 : Python 3.6.8
사용 프로그램 : Atom 1.34.0 x64
open() 괄호에는 파일을 열 경로를, read() 괄호에는 읽을 데이터양을 적습니다.
open().read()는 파일을 열고, str 형식으로 읽습니다.
"shakespeare.txt" 내용입니다.
이번에는 read에 읽을 데이터양을 설정한 뒤 실행해 보겠습니다.
다음과 같이 정해진 길이만큼만 읽어들였습니다.
읽은 파일은 리스트가 아닌, 하나의 문자열로 취급됩니다.
끝.
사용 프로그램 : Atom 1.34.0 x64
파이썬 open().read()에 대해서 알아보겠습니다.
open() 괄호에는 파일을 열 경로를, read() 괄호에는 읽을 데이터양을 적습니다.
open().read()는 파일을 열고, str 형식으로 읽습니다.
"shakespeare.txt" 내용입니다.



이번에는 read에 읽을 데이터양을 설정한 뒤 실행해 보겠습니다.


다음과 같이 정해진 길이만큼만 읽어들였습니다.
읽은 파일은 리스트가 아닌, 하나의 문자열로 취급됩니다.


끝.
카테고리: Standard Library, Python
댓글
댓글 쓰기
궁금한 점은 댓글 달아주세요.
Comment if you have any questions.