728x90 반응형 binary3 Text File and Binary File: Hex Code Text파일과 Binary 파일의 차이를 이해하기 위한 문서임:Text 파일의 각 글자의 Encoding (UTF-8)된 binary code를 Hexadecimal 형태로 살펴보고Binary 파일의 0과 1의 표현을 JPEG 이미지 파일을 사용하여 Hexadecimal 형태로 살펴본다. 이를 살펴보기 위해 VSCode에 HEX Editor Extension을 설치하여 살펴봄. UTF-8에 대한 자세한 내용은 다음을 참고:https://dsaint31.me/mkdocs_site/CE/ch01/code_for_character/?h=ascii#utf-8-universal-coded-character-set-transformation-format-8-bit BMECodes for Characters Cod.. 2025. 3. 11. [Python] bytes and bytearray: Binary Data for Python Python에서 bytes와 bytearray는binary data를 byte 단위 (1byte = 8bit)로 다루는데사용되는 Data Type임.bytes:bytes 는 immutable byte sequence 로서 일종의 byte로 구성된 tuple에 해당 함.byte literal은 다음과 같이 b라는 prefix를 사용함.b'Hello'은 'Hello'라는 문자열에 대한 byte literal을 의미함.문자열에 대한 bytes 이므로 encoding이 사용되며 기본으로 utf8이 사용됨.byte literal과 같이 추후 변경이 되지 않는 binary data를 위한 데이터 타입이 bytes임.bytes 객체를 출력할 경우,utf8인 경우에는 ascii에 해당하는 바이트는 ascii 문자로 출.. 2024. 1. 15. [python] Text mode vs. Binary mode: File open Python에서 특정 파일을 open하는 경우, text mode 또는 binary mode 중 하나로 열게 된다.기본은 text mode임. 이 둘의 차이점은 간단히 설명하면,현재 open하고자 하는 file을 text파일로 처리할지아니면 binary파일로 처리할지를 결정하는 것임.1. binary mode 로 file을 여는 경우,Python은 해당 file을 순수한 bytes의 형태로 취급함: bytes, bytearray 로 처리해당 파일을 byte 단위로 읽어들이면서어떠한 변환없이 file에 기재된 bytes 의 값들을 그대로 읽어들임.2. text mode로 file을 여는 경우,사람이 읽을 수 있는 문자들로 구성된 text file이라고 생각: str 로 처리file의 bytes 값들을 사.. 2024. 1. 15. 이전 1 다음 728x90 반응형