File 열고 닫기.
2023.07.04 - [Python] - [Python] file : open and close
[Python] file : open and close
Python 에서 file을 처리하기 위해선 다른 프로그래밍 언어와 마찬가지로 file에 대한 접근이 가능한 object를 얻어와야함. 이같은 object는 file handler, file descriptor 등의 여러 이름으로 불리며, 이를 얻
ds31x.tistory.com
Text file 처리
2023.07.04 - [Python] - [Python] Text File : read and write
[Python] Text File : read and write
쓰기 open으로 얻은 file object의 메서드 write 또는 print 함수를 통해 쓰기를 수행함. 당연히 해당 file object는 wt or w 등과 같이 Text file로 쓰기 (or a or x)등으로 열려야 함. 2023.07.04 - [Python] - [Python] file :
ds31x.tistory.com
Binary file 처리
2023.07.04 - [Python] - [Python] binary file : write and read
[Python] binary file : write and read
txt file과 거의 비슷하나, 다음의 차이를 보임. 파일 내용을 담는데 사용하는 class가 str을 주로 쓰는 txt file의 경우와 달리 bytes와 bytearray를 사용한다. bytes는 immutable이고, bytearray는 mutable인 점을 기
ds31x.tistory.com
Binary File의 특별한 사용: pickle (Serialization)
2024.11.27 - [Python] - [Py] Serialization of Python: pickle
[Py] Serialization of Python: pickle
1. Python의 pickle 모듈Python의 pickle 모듈은 Python 객체를 직렬화(serialize)하여 파일 또는 메모리에 저장.저장된 데이터를 다시 역직렬화(deserialize)하여 원래 객체로 복원.데이터를 영구 저장하거나 네
ds31x.tistory.com
Binary File의 특별한 사용: struct 모듈 (기본일 때는 생략)
2024.01.15 - [Python] - [Python] struct 사용하기: bytes 로 C언어 구조체 다루기.
[Python] struct 사용하기: bytes 로 C언어 구조체 다루기.
struct 모듈binary data를 보다 쉽게 파싱해주는 기능을 제공한다. C언어의 구조체로 명시된 binary data를 네트워크 등으로 받은 경우나,binary format으로 특정 header정보를 가지고 있는 파일들을 읽어들
ds31x.tistory.com
Text mode vs. Binary mode
2024.01.15 - [Python] - [python] Text mode vs. Binary mode: File open
[python] Text mode vs. Binary mode: File open
Python에서 특정 파일을 open하는 경우, text mode 또는 binary mode 중 하나로 열게 된다. 이 둘의 차이점은 간단히 설명하면, 현재 open하고자 하는 file을 text파일로 처리할지 아니면 binary파일로 처리할지
ds31x.tistory.com
Memory 기반 Stream: BytesIO & StringIO
2024.12.03 - [Python] - [Py] io.StringIO 와 io.BytesIO
[Py] io.StringIO 와 io.BytesIO
io.StringIO와 io.BytesIO는Python의 io 모듈에서 제공하는 메모리 기반 파일 객체(memory-based file object)임.이들은 데이터를 메모리에 저장하면서 파일처럼 다룰 수 있는 기능을 제공함.두 클래스는 파일
ds31x.tistory.com
File 및 Directory 처리 (Path 등에 대한)
[Python] os 모듈의 함수들 : file과 directory 관련
os는 operating system (운영체제)와 상호작용을 위한 다양한 기능을 제공하는 built-in module임. 대부분 os 종속적인 기능들이다. os.path 모듈 ds_exist = os.path.exists('path') path가 실제로 존재하는 파일 또는
ds31x.tistory.com
[Python] pathlib.Path 사용하기.
Path 모듈은 file 및 directory의 path 를 객체지향적으로 취급하기 쉬운 인터페이스를 제공하는 Python 표준 라이브러리임. Python 3.4 이상에서 사용가능함. Path 인스턴스 생성. from pathlib import Path # current
ds31x.tistory.com
'Python' 카테고리의 다른 글
[Python] Terminal, WSL, Conda, and VSCode (1) | 2023.12.15 |
---|---|
[Etc] Token and Tokenizer (2) | 2023.12.06 |
[Python] Programming Language and Introduction of Python. (1) | 2023.10.23 |
[Python] __name__ : Special string variable (0) | 2023.10.10 |
[Python] input 함수 사용하여 사용자 입력받기. (0) | 2023.10.10 |