ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Python
    스트림 IO/텍스트 프로세싱 2017. 5. 4. 17:28

    open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)    # TextIOWrapper

    파일모드에는 읽기(r), 쓰기(w 혹은 x), 추가(a), 수정(+) 모드를 지정할 수 있으며, 텍스트 파일(t), 바이너리 파일(b) 를 지정할 수 있다. 특히, w 모드는 파일이 이미 있으면, 먼저 그 내용을 삭제하고 새로 시작하지만, x 모드는 파일이 이미 있으면, FileExistsError 를 발생시킨다. 만약 파일모드를 지정하지 않으면, 디폴트로 텍스트 읽기 (rt) 모드가 설정된다.

    For binary read-write access, the mode 'w+b' opens and truncates the file to 0 bytes. 'r+b' opens the file without truncation.


    TextIOWrapper

    .close()

    .read()

    .readline()

    .readlines()

    .write()

    .writelines()


    - 탭을 4개의 공백으로 바꾸기



    참조 사이트:

    https://wikidocs.net/37

    http://pythonstudy.xyz/python/article/206-%ED%8C%8C%EC%9D%BC-%EB%8D%B0%EC%9D%B4%ED%83%80-%EC%B2%98%EB%A6%AC

    https://docs.python.org/3.4/library/functions.html#open


Designed by Tistory.