René's URL Explorer Experiment


Title: Bytes Objects: Handling Binary Data in Python – Real Python

Open Graph Title: Bytes Objects: Handling Binary Data in Python – Real Python

Description: In this tutorial, you'll learn about Python's bytes objects, which help you process low-level binary data. You'll explore how to create and manipulate byte sequences in Python and how to convert between bytes and strings. Additionally, you'll practice this knowledge by coding a few fun examples.

Open Graph Description: In this tutorial, you'll learn about Python's bytes objects, which help you process low-level binary data. You'll explore how to create and manipulate byte sequences in Python and how to convert between bytes and strings. Additionally, you'll practice this knowledge by coding a few fun examples.

Mail addresses
?subject=Python article for you&body=Bytes Objects: Handling Binary Data in Python on Real Python https://realpython.com/python-bytes/

Opengraph URL: https://realpython.com/python-bytes/

X: @realpython

direct link

Domain: realpython.com


Hey, it has json ld scripts:
{
  "@context": "http://schema.org",
  "@type": "Article",
  "headline": "Bytes Objects: Handling Binary Data in Python",
  "image": {
    "@type": "ImageObject",
    "url": "https://files.realpython.com/media/Pythons-Bytes-Data-Type_Watermarked.f92d44bd7034.jpg",
    "width": 1920,
    "height": 1080
  },
  "mainEntityOfPage": {
    "@type": "WebPage",
    "@id": "https://realpython.com/python-bytes/",
    "lastReviewed": "2025-01-20",
    "author": {
      "@type": "Person",
      "name": "Bartosz Zaczy\u0144ski",
      "image": "https://realpython.com/cdn-cgi/image/width=1694,height=1694,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/coders_lab_2109368.259b1599fbee.jpg",
      "url": "https://realpython.com/team/bzaczynski/",
      "affiliation": {
        "@type": "Organization",
        "@id": "https://realpython.com/#organization",
        "name": "Real Python",
        "url": "https://realpython.com",
        "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
      }
    },
    "reviewedBy": [
      {
        "@type": "Person",
        "name": "Aldren Santos",
        "image": "https://realpython.com/cdn-cgi/image/width=500,height=500,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/Aldren_Santos_Real_Python.6b0861d8b841.png",
        "url": "https://realpython.com/team/asantos/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      },
      {
        "@type": "Person",
        "name": "Brenda Weleschuk",
        "image": "https://realpython.com/cdn-cgi/image/width=320,height=320,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/IMG_3324_1.50b309355fc1.jpg",
        "url": "https://realpython.com/team/bweleschuk/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      },
      {
        "@type": "Person",
        "name": "Geir Arne Hjelle",
        "image": "https://realpython.com/cdn-cgi/image/width=800,height=800,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/gahjelle.470149ee709e.jpg",
        "url": "https://realpython.com/team/gahjelle/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      },
      {
        "@type": "Person",
        "name": "Leodanis Pozo Ramos",
        "image": "https://realpython.com/cdn-cgi/image/width=862,height=862,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/Perfil_final1.9f896bc212f6.jpg",
        "url": "https://realpython.com/team/lpozoramos/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      },
      {
        "@type": "Person",
        "name": "Stephen Gruppetta",
        "image": "https://realpython.com/cdn-cgi/image/width=400,height=400,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/Stephen_inside_2_BW_2_square_crop_2_low_res_2_copy.4a7e2d8bc19c.png",
        "url": "https://realpython.com/team/sgruppetta/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      }
    ]
  },
  "datePublished": "2025-03-05T14:00:00+00:00",
  "dateModified": "2025-01-20T13:27:59.334235+00:00",
  "publisher": {
    "@type": "Organization",
    "@id": "https://realpython.com/#organization",
    "name": "Real Python",
    "url": "https://realpython.com",
    "logo": {
      "@type": "ImageObject",
      "url": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png",
      "width": 512,
      "height": 512
    },
    "description": "Real Python is a leading provider of online Python education and one of the largest language-specific online communities for software developers. It publishes high-quality learning resources, such as tutorials, books, and courses to an audience of millions of developers, data scientists, and machine learning engineers each month.",
    "slogan": "Become a Python Expert",
    "email": "info@realpython.com",
    "sameAs": [
      "https://github.com/realpython",
      "https://www.youtube.com/realpython",
      "https://twitter.com/realpython",
      "https://x.com/realpython",
      "https://www.linkedin.com/company/realpython-com/",
      "https://www.facebook.com/learnrealpython",
      "https://www.instagram.com/realpython",
      "https://www.tiktok.com/@realpython.com"
    ]
  },
  "author": {
    "@type": "Person",
    "name": "Bartosz Zaczy\u0144ski",
    "image": "https://realpython.com/cdn-cgi/image/width=1694,height=1694,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/coders_lab_2109368.259b1599fbee.jpg",
    "url": "https://realpython.com/team/bzaczynski/",
    "affiliation": {
      "@type": "Organization",
      "@id": "https://realpython.com/#organization",
      "name": "Real Python",
      "url": "https://realpython.com",
      "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
    }
  },
  "description": "In this tutorial, you'll learn about Python's bytes objects, which help you process low-level binary data. You'll explore how to create and manipulate byte sequences in Python and how to convert between bytes and strings. Additionally, you'll practice this knowledge by coding a few fun examples.",
  "hasPart": {
    "@type": "FAQPage",
    "mainEntity": [
      {
        "@type": "Question",
        "name": "What are Python bytes objects?",
        "acceptedAnswer": {
          "@type": "Answer",
          "text": "

bytes objects in Python are immutable sequences of unsigned 8-bit integers, used to handle binary data.

" } }, { "@type": "Question", "name": "How do you create a bytes object in Python?", "acceptedAnswer": { "@type": "Answer", "text": "

You can create a bytes object by using a bytes literal, the bytes() function, or the bytes.fromhex() method.

" } }, { "@type": "Question", "name": "What is the difference between bytes and bytearray?", "acceptedAnswer": { "@type": "Answer", "text": "

While both represent sequences of bytes, bytes is immutable, whereas bytearray is mutable, allowing modifications.

" } }, { "@type": "Question", "name": "How to convert a string to bytes in Python?", "acceptedAnswer": { "@type": "Answer", "text": "

You convert a string to bytes by using the str.encode() method and specifying the desired character encoding.

" } }, { "@type": "Question", "name": "What is endianness in binary data handling?", "acceptedAnswer": { "@type": "Answer", "text": "

Endianness refers to the order of bytes in multi-byte data types, either starting with the least significant byte (little-endian) or the most significant byte (big-endian).

" } } ] } }

authorReal Python
twitter:cardsummary_large_image
twitter:imagehttps://files.realpython.com/media/Pythons-Bytes-Data-Type_Watermarked.f92d44bd7034.jpg
og:imagehttps://files.realpython.com/media/Pythons-Bytes-Data-Type_Watermarked.f92d44bd7034.jpg
twitter:creator@realpython
og:typearticle

Links:

https://realpython.com/
Start Herehttps://realpython.com/start-here/
Learn Python https://realpython.com/python-bytes/
Python Tutorials →In-depth articles and video courseshttps://realpython.com/search?kind=article&kind=course&order=newest
Learning Paths →Guided study plans for accelerated learninghttps://realpython.com/learning-paths/
Quizzes & Exercises →Check your learning progresshttps://realpython.com/quizzes/
Browse Topics →Focus on a specific area or skill levelhttps://realpython.com/tutorials/all/
Community Chat →Learn with other Pythonistashttps://realpython.com/community/
Office Hours →Live Q&A calls with Python expertshttps://realpython.com/office-hours/
Podcast →Hear what’s new in the world of Pythonhttps://realpython.com/podcasts/rpp/
Books →Round out your knowledge and learn offlinehttps://realpython.com/products/books/
Reference →Concise definitions for common Python termshttps://realpython.com/ref/
Code Mentor →BetaPersonalized code assistance & learning toolshttps://realpython.com/mentor/
Unlock All Content →https://realpython.com/account/join/
More https://realpython.com/python-bytes/
Learner Storieshttps://realpython.com/learner-stories/
Python Newsletterhttps://realpython.com/newsletter/
Python Job Boardhttps://www.pythonjobshq.com
Meet the Teamhttps://realpython.com/team/
Become a Tutorial Writerhttps://realpython.com/write-for-us/
Become a Video Instructorhttps://realpython.com/become-an-instructor/
Searchhttps://realpython.com/search
https://realpython.com/search
Joinhttps://realpython.com/account/join/
Sign‑Inhttps://realpython.com/account/login/?next=%2Fpython-bytes%2F
Browse Topicshttps://realpython.com/tutorials/all/
Guided Learning Pathshttps://realpython.com/learning-paths/
Basicshttps://realpython.com/search?level=basics
Intermediatehttps://realpython.com/search?level=intermediate
Advancedhttps://realpython.com/search?level=advanced
aihttps://realpython.com/tutorials/ai/
algorithmshttps://realpython.com/tutorials/algorithms/
apihttps://realpython.com/tutorials/api/
best-practiceshttps://realpython.com/tutorials/best-practices/
careerhttps://realpython.com/tutorials/career/
communityhttps://realpython.com/tutorials/community/
databaseshttps://realpython.com/tutorials/databases/
data-sciencehttps://realpython.com/tutorials/data-science/
data-structureshttps://realpython.com/tutorials/data-structures/
data-vizhttps://realpython.com/tutorials/data-viz/
devopshttps://realpython.com/tutorials/devops/
djangohttps://realpython.com/tutorials/django/
dockerhttps://realpython.com/tutorials/docker/
editorshttps://realpython.com/tutorials/editors/
flaskhttps://realpython.com/tutorials/flask/
front-endhttps://realpython.com/tutorials/front-end/
gamedevhttps://realpython.com/tutorials/gamedev/
guihttps://realpython.com/tutorials/gui/
machine-learninghttps://realpython.com/tutorials/machine-learning/
newshttps://realpython.com/tutorials/news/
numpyhttps://realpython.com/tutorials/numpy/
projectshttps://realpython.com/tutorials/projects/
pythonhttps://realpython.com/tutorials/python/
stdlibhttps://realpython.com/tutorials/stdlib/
testinghttps://realpython.com/tutorials/testing/
toolshttps://realpython.com/tutorials/tools/
web-devhttps://realpython.com/tutorials/web-dev/
web-scrapinghttps://realpython.com/tutorials/web-scraping/
Table of Contentshttps://realpython.com/python-bytes/#toc
Brushing Up on Binary Fundamentalshttps://realpython.com/python-bytes/#brushing-up-on-binary-fundamentals
Bits, Bytes, and Binary Datahttps://realpython.com/python-bytes/#bits-bytes-and-binary-data
Binary Words and Endiannesshttps://realpython.com/python-bytes/#binary-words-and-endianness
Signedness and the Sign Bithttps://realpython.com/python-bytes/#signedness-and-the-sign-bit
Two’s Complement vs Pythonhttps://realpython.com/python-bytes/#twos-complement-vs-python
Getting to Know the bytes Object in Pythonhttps://realpython.com/python-bytes/#getting-to-know-the-bytes-object-in-python
Bytes-Like Objects and byteshttps://realpython.com/python-bytes/#bytes-like-objects-and-bytes
Python’s Buffer Protocolhttps://realpython.com/python-bytes/#pythons-buffer-protocol
Creating Python bytes by Handhttps://realpython.com/python-bytes/#creating-python-bytes-by-hand
The Bytes Literal Formathttps://realpython.com/python-bytes/#the-bytes-literal-format
The Built-in bytes() Functionhttps://realpython.com/python-bytes/#the-built-in-bytes-function
The bytes.fromhex() Class Methodhttps://realpython.com/python-bytes/#the-bytesfromhex-class-method
Manipulating Bytes Objects in Pythonhttps://realpython.com/python-bytes/#manipulating-bytes-objects-in-python
Use bytes Like a Python Stringhttps://realpython.com/python-bytes/#use-bytes-like-a-python-string
Convert Between Bytes and Stringshttps://realpython.com/python-bytes/#convert-between-bytes-and-strings
Represent Bytes in Python Differentlyhttps://realpython.com/python-bytes/#represent-bytes-in-python-differently
Working With Python Bytes in Practicehttps://realpython.com/python-bytes/#working-with-python-bytes-in-practice
Read and Write Binary Files of Varying Sizeshttps://realpython.com/python-bytes/#read-and-write-binary-files-of-varying-sizes
Communicate Over a Binary Network Protocolhttps://realpython.com/python-bytes/#communicate-over-a-binary-network-protocol
Serialize Python Objects Using a Binary Formathttps://realpython.com/python-bytes/#serialize-python-objects-using-a-binary-format
Manipulate Pixel Data to Conceal a Hidden Messagehttps://realpython.com/python-bytes/#manipulate-pixel-data-to-conceal-a-hidden-message
Embed an Image in Markdown Using Base64https://realpython.com/python-bytes/#embed-an-image-in-markdown-using-base64
Compile and Execute Python Bytecodehttps://realpython.com/python-bytes/#compile-and-execute-python-bytecode
Conclusionhttps://realpython.com/python-bytes/#conclusion
Frequently Asked Questionshttps://realpython.com/python-bytes/#frequently-asked-questions
https://realpython.com/feedback/survey/article/python-bytes/liked/?from=article-sidebar
https://realpython.com/feedback/survey/article/python-bytes/disliked/?from=article-sidebar
Bartosz Zaczyńskihttps://realpython.com/python-bytes/#author
https://realpython.com/python-bytes/#reader-comments
intermediatehttps://realpython.com/tutorials/intermediate/
pythonhttps://realpython.com/tutorials/python/
Brushing Up on Binary Fundamentalshttps://realpython.com/python-bytes/#brushing-up-on-binary-fundamentals
Bits, Bytes, and Binary Datahttps://realpython.com/python-bytes/#bits-bytes-and-binary-data
Binary Words and Endiannesshttps://realpython.com/python-bytes/#binary-words-and-endianness
Signedness and the Sign Bithttps://realpython.com/python-bytes/#signedness-and-the-sign-bit
Two’s Complement vs Pythonhttps://realpython.com/python-bytes/#twos-complement-vs-python
Getting to Know the bytes Object in Pythonhttps://realpython.com/python-bytes/#getting-to-know-the-bytes-object-in-python
Bytes-Like Objects and byteshttps://realpython.com/python-bytes/#bytes-like-objects-and-bytes
Python’s Buffer Protocolhttps://realpython.com/python-bytes/#pythons-buffer-protocol
Creating Python bytes by Handhttps://realpython.com/python-bytes/#creating-python-bytes-by-hand
The Bytes Literal Formathttps://realpython.com/python-bytes/#the-bytes-literal-format
The Built-in bytes() Functionhttps://realpython.com/python-bytes/#the-built-in-bytes-function
The bytes.fromhex() Class Methodhttps://realpython.com/python-bytes/#the-bytesfromhex-class-method
Manipulating Bytes Objects in Pythonhttps://realpython.com/python-bytes/#manipulating-bytes-objects-in-python
Use bytes Like a Python Stringhttps://realpython.com/python-bytes/#use-bytes-like-a-python-string
Convert Between Bytes and Stringshttps://realpython.com/python-bytes/#convert-between-bytes-and-strings
Represent Bytes in Python Differentlyhttps://realpython.com/python-bytes/#represent-bytes-in-python-differently
Working With Python Bytes in Practicehttps://realpython.com/python-bytes/#working-with-python-bytes-in-practice
Read and Write Binary Files of Varying Sizeshttps://realpython.com/python-bytes/#read-and-write-binary-files-of-varying-sizes
Communicate Over a Binary Network Protocolhttps://realpython.com/python-bytes/#communicate-over-a-binary-network-protocol
Serialize Python Objects Using a Binary Formathttps://realpython.com/python-bytes/#serialize-python-objects-using-a-binary-format
Manipulate Pixel Data to Conceal a Hidden Messagehttps://realpython.com/python-bytes/#manipulate-pixel-data-to-conceal-a-hidden-message
Embed an Image in Markdown Using Base64https://realpython.com/python-bytes/#embed-an-image-in-markdown-using-base64
Compile and Execute Python Bytecodehttps://realpython.com/python-bytes/#compile-and-execute-python-bytecode
Conclusionhttps://realpython.com/python-bytes/#conclusion
Frequently Asked Questionshttps://realpython.com/python-bytes/#frequently-asked-questions
Remove adshttps://realpython.com/account/join/
Python basicshttps://realpython.com/python-basics-paperback/
built-in data typeshttps://realpython.com/python-data-types/
Click here to download the free sample codehttps://realpython.com/bonus/python-bytes-code/
https://realpython.com/quizzes/python-bytes/
Python Byteshttps://realpython.com/quizzes/python-bytes/
https://realpython.com/python-bytes/#brushing-up-on-binary-fundamentals
creating bytes objectshttps://realpython.com/python-bytes/#creating-python-bytes-by-hand
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-bytes/#bits-bytes-and-binary-data
binary digitshttps://en.wikipedia.org/wiki/Binary_number
octethttps://en.wikipedia.org/wiki/Octet_(computing)
24-bit color depthhttps://en.wikipedia.org/wiki/Color_depth#True_color_(24-bit)
primary colorshttps://en.wikipedia.org/wiki/Primary_color
RGB color modelhttps://en.wikipedia.org/wiki/RGB_color_model
RGB color spacehttps://en.wikipedia.org/wiki/RGB_color_spaces
additivehttps://en.wikipedia.org/wiki/Additive_color
subtractivehttps://en.wikipedia.org/wiki/Subtractive_color
Python REPLhttps://realpython.com/python-repl/
hexadecimal numeral systemhttps://en.wikipedia.org/wiki/Hexadecimal
hex()https://realpython.com/ref/builtin-functions/hex/
online color pickerhttps://www.google.com/search?q=color+picker
https://files.realpython.com/media/color_picker.5551b505f58c.png
alignedhttps://en.wikipedia.org/wiki/Data_structure_alignment
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-bytes/#binary-words-and-endianness
binary wordhttps://en.wikipedia.org/wiki/Word_(computer_architecture)
Javahttps://realpython.com/java-vs-python/
endiannesshttps://en.wikipedia.org/wiki/Endianness
least significant bytehttps://en.wikipedia.org/wiki/Bit_numbering#Least_significant_byte
bit numberinghttps://en.wikipedia.org/wiki/Bit_numbering
syshttps://docs.python.org/3/library/sys.html
bi-endianhttps://en.wikipedia.org/wiki/Endianness#Bi-endianness
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-bytes/#signedness-and-the-sign-bit
unsigned integerhttps://realpython.com/python-bitwise-operators/#unsigned-integers
signed integerhttps://realpython.com/python-bitwise-operators/#signed-integers
floating-point numberhttps://realpython.com/python-numbers/#floating-point-numbers
sign, exponent, and mantissahttps://en.wikipedia.org/wiki/Floating-point_arithmetic
half-precisionhttps://en.wikipedia.org/wiki/Half-precision_floating-point_format
single precisionhttps://en.wikipedia.org/wiki/Single-precision_floating-point_format
double precisionhttps://en.wikipedia.org/wiki/Double-precision_floating-point_format
signednesshttps://en.wikipedia.org/wiki/Signedness
numeric typeshttps://realpython.com/python-numbers/
signed number representationshttps://en.wikipedia.org/wiki/Signed_number_representations
sign bithttps://en.wikipedia.org/wiki/Sign_bit
two’s complementhttps://en.wikipedia.org/wiki/Two%27s_complement
Python’s integer representationshttps://realpython.com/python-bitwise-operators/#integers-in-python
emulate the sign bithttps://realpython.com/python-bitwise-operators/#emulating-the-sign-bit
https://realpython.com/python-bytes/#twos-complement-vs-python
byteshttps://realpython.com/python-bytes/#getting-to-know-the-bytes-object-in-python
exceptionhttps://realpython.com/python-exceptions/
range()https://realpython.com/python-range/
right-open intervalhttps://en.wikipedia.org/wiki/Interval_(mathematics)
.to_bytes()https://docs.python.org/3/library/stdtypes.html#int.to_bytes
.from_bytes()https://docs.python.org/3/library/stdtypes.html#int.from_bytes
loophttps://realpython.com/python-for-loop/
overflow errorhttps://realpython.com/python-built-in-exceptions/#overflowerror
bitmaskshttps://realpython.com/python-bitwise-operators/#bitmasks
modulo operator (%)https://realpython.com/python-modulo-operator/
bitwise operatorshttps://realpython.com/python-bitwise-operators/
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-bytes/#getting-to-know-the-bytes-object-in-python
batteries includedhttps://docs.python.org/3/tutorial/stdlib.html#batteries-included
standard libraryhttps://realpython.com/ref/glossary/standard-library/
third-party packagehttps://realpython.com/python-package-quality/
https://realpython.com/python-bytes/#bytes-like-objects-and-bytes
https://files.realpython.com/media/byte_sequences2.87a74e8278cd.png
code pagehttps://en.wikipedia.org/wiki/Code_page
alpha channelhttps://en.wikipedia.org/wiki/Alpha_compositing
file headerhttps://en.wikipedia.org/wiki/Header_(computing)
GPS coordinateshttps://en.wikipedia.org/wiki/Global_Positioning_System
binary sequence typeshttps://docs.python.org/3/library/stdtypes.html#binaryseq
mutablehttps://realpython.com/python-mutable-vs-immutable-types/
bytes-like objecthttps://realpython.com/ref/glossary/bytes-like-object/
file-like objecthttps://docs.python.org/3/glossary.html#term-file-like-object
array data structurehttps://realpython.com/python-array/
mappinghttps://realpython.com/python-map-function/
chr()https://realpython.com/ref/builtin-functions/chr/
.join()https://realpython.com/python-join-string/
ASCIIhttps://en.wikipedia.org/wiki/ASCII
Unicodehttps://realpython.com/python-encodings-guide/
accented letter éhttps://www.compart.com/en/unicode/U+00E9
arrayhttps://docs.python.org/3/library/array.html
Pillowhttps://realpython.com/image-processing-with-the-python-pillow-library/
image modehttps://pillow.readthedocs.io/en/stable/handbook/concepts.html#modes
swap the byteshttps://docs.python.org/3/library/array.html#array.array.byteswap
structhttps://docs.python.org/3/library/struct.html
format stringhttps://docs.python.org/3/library/struct.html#struct-format-strings
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-bytes/#pythons-buffer-protocol
buffer protocolhttps://realpython.com/ref/glossary/buffer-protocol/
data buffershttps://en.wikipedia.org/wiki/Data_buffer
NumPy arrayhttps://realpython.com/numpy-array-programming/
Portable Network Graphics (PNG)https://en.wikipedia.org/wiki/PNG
C extension moduleshttps://realpython.com/build-python-c-extension-module/
memory leakshttps://en.wikipedia.org/wiki/Memory_leak
segmentation faultshttps://en.wikipedia.org/wiki/Segmentation_fault
strideshttps://en.wikipedia.org/wiki/Stride_of_an_array
PEP 688https://peps.python.org/pep-0688/
Python 3.12https://realpython.com/python312-new-features/
special methodshttps://realpython.com/python-magic-methods/
Python classeshttps://realpython.com/python-classes/
memoryview()https://docs.python.org/3/library/stdtypes.html#memoryview
https://realpython.com/python-bytes/#creating-python-bytes-by-hand
https://realpython.com/python-bytes/#the-bytes-literal-format
string literalhttps://realpython.com/python-strings/#standard-string-literals
constanthttps://realpython.com/python-constants/
binary file signaturehttps://en.wikipedia.org/wiki/File_format#Magic_number
string and bytes literalshttps://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals
escape sequencehttps://docs.python.org/3/reference/lexical_analysis.html#escape-sequences
raw string literalhttps://realpython.com/python-raw-strings/
regular expressionshttps://realpython.com/regex-python/
Exifhttps://en.wikipedia.org/wiki/Exif
formatted string literalshttps://realpython.com/python-f-strings/
f-stringshttps://realpython.com/ref/glossary/f-string/
end of the file (EOF)https://en.wikipedia.org/wiki/End-of-file
file.read()https://docs.python.org/3/library/io.html#io.BufferedReader.read
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-bytes/#the-built-in-bytes-function
class constructorhttps://realpython.com/python-class-constructor/
Python functionhttps://realpython.com/defining-your-own-python-function/
built-in functionhttps://realpython.com/python-built-in-functions/
bytes()https://docs.python.org/3/library/functions.html#func-bytes
sentinel valuehttps://en.wikipedia.org/wiki/Sentinel_value
bitmap imagehttps://realpython.com/python-bitwise-operators/#bitmap-file-format
bytearrayhttps://realpython.com/python-bytearray/
lists and tupleshttps://realpython.com/python-lists-tuples/
.__bytes__()https://docs.python.org/3/reference/datamodel.html#object.__bytes__
.__buffer__()https://docs.python.org/3/reference/datamodel.html#object.__buffer__
iterablehttps://realpython.com/python-iterators-iterables/
lazily evaluatedhttps://realpython.com/python-lazy-evaluation/
itertoolshttps://realpython.com/python-itertools/
code pointshttps://en.wikipedia.org/wiki/Code_point
Pythonichttps://realpython.com/learning-paths/writing-pythonic-code/
str.encode()https://docs.python.org/3/library/stdtypes.html#str.encode
ordinal valuehttps://docs.python.org/3/library/functions.html#ord
handling encoding errorshttps://docs.python.org/3/library/codecs.html#error-handlers
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-bytes/#the-bytesfromhex-class-method
class methodhttps://realpython.com/instance-class-and-static-methods-demystified/#class-methods
https://realpython.com/python-bytes/#manipulating-bytes-objects-in-python
https://realpython.com/python-bytes/#use-bytes-like-a-python-string
C programming languagehttps://realpython.com/c-for-python-programmers/
release noteshttps://docs.python.org/3/whatsnew/3.0.html#text-vs-data-instead-of-unicode-vs-8-bit
Python sequenceshttps://realpython.com/python-sequences/
Indexinghttps://realpython.com/python-strings/#indexing-strings
Slicinghttps://realpython.com/python-strings/#slicing-strings
Iteratinghttps://realpython.com/python-iterators-iterables/#understanding-iteration-in-python
Reversinghttps://realpython.com/reverse-string-python/
Measuring the Lengthhttps://realpython.com/len-python-function/
Finding the Indexhttps://realpython.com/python-strings/#indexsub-start-end
Counting Occurrenceshttps://realpython.com/python-strings/#countsub-start-end
Checking Membershiphttps://realpython.com/python-in-operator/
concatenatehttps://realpython.com/python-string-concatenation/
preamblehttps://en.wikipedia.org/wiki/Syncword
start frame delimiter (SFD)https://en.wikipedia.org/wiki/Ethernet_frame#SFD
Ethernet packethttps://en.wikipedia.org/wiki/Ethernet_frame
Counterhttps://realpython.com/python-counter/
collectionshttps://realpython.com/python-collections-module/
mappinghttps://realpython.com/python-mappings/
hexspeakhttps://en.wikipedia.org/wiki/Hexspeak
finding and replacing substringshttps://realpython.com/python-strings/#finding-and-replacing-substrings
splittinghttps://realpython.com/python-split-string/
joininghttps://realpython.com/python-join-string/
assignmentshttps://realpython.com/python-assignment-operator/
deletionshttps://realpython.com/python-del-statement/
over a millionhttps://docs.python.org/3/library/sys.html#sys.maxunicode
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-bytes/#convert-between-bytes-and-strings
str.encode()https://docs.python.org/3/library/stdtypes.html#str.encode
bytes.decode()https://docs.python.org/3/library/stdtypes.html#bytes.decode
str()https://docs.python.org/3/library/functions.html#func-str
codecshttps://docs.python.org/3/library/codecs.html
UTF-8https://en.wikipedia.org/wiki/UTF-8
UTF-8 as the default encodinghttps://peps.python.org/pep-0686/
Base64https://en.wikipedia.org/wiki/Base64
ROT-13https://en.wikipedia.org/wiki/ROT13
https://realpython.com/python-bytes/#represent-bytes-in-python-differently
carriage returnhttps://en.wikipedia.org/wiki/Carriage_return
debugginghttps://realpython.com/python-debugging-pdb/
generator expressionhttps://realpython.com/introduction-to-python-generators/#building-generators-with-generator-expressions
format()https://realpython.com/ref/builtin-functions/format/
bytes.hex()https://docs.python.org/3/library/stdtypes.html#bytes.hex
IPv6 addresseshttps://en.wikipedia.org/wiki/IPv6
bytes-like objects and byteshttps://realpython.com/python-bytes/#bytes-like-objects-and-bytes
picklehttps://realpython.com/python-pickle-module/
serialize datahttps://realpython.com/python-serialize-data/
certain data formathttps://docs.python.org/3/library/pickle.html#data-stream-format
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-bytes/#working-with-python-bytes-in-practice
https://realpython.com/python-bytes/#read-and-write-binary-files-of-varying-sizes
pathlibhttps://realpython.com/python-pathlib/
MD5 digesthttps://en.wikipedia.org/wiki/MD5
checksumhttps://en.wikipedia.org/wiki/Checksum
walrus operator (:=)https://realpython.com/python-walrus-operator/
mmaphttps://realpython.com/python-mmap/
OpenStreetMap (OSM)https://www.openstreetmap.org/
XMLhttps://realpython.com/python-xml-parser/
seek a specific byte offsethttps://docs.python.org/3/library/io.html#io.IOBase.seek
reading and writing WAV files in Pythonhttps://realpython.com/python-wav-files/
maze solverhttps://realpython.com/python-maze-solver/#step-4-load-the-maze-from-a-binary-file
https://realpython.com/python-bytes/#communicate-over-a-binary-network-protocol
communication protocolshttps://en.wikipedia.org/wiki/Communication_protocol
HTTPhttps://en.wikipedia.org/wiki/HTTP
HTTPShttps://realpython.com/python-https/
software development kits (SDKs)https://en.wikipedia.org/wiki/Software_development_kit
socket programminghttps://realpython.com/python-sockets/
Redishttps://realpython.com/python-redis/
redis-pyhttps://redis.io/docs/latest/develop/clients/redis-py/
RESPhttps://redis.io/docs/latest/develop/reference/protocol-spec/
carriage return (CR)https://en.wikipedia.org/wiki/Carriage_return
line feed (LF)https://en.wikipedia.org/wiki/Newline
bulk stringhttps://redis.io/docs/latest/develop/reference/protocol-spec/#bulk-strings
request-response modelhttps://redis.io/docs/latest/develop/reference/protocol-spec/#request-response-model
arrayhttps://redis.io/docs/latest/develop/reference/protocol-spec/#arrays
Redis commandhttps://redis.io/docs/latest/commands/
PINGhttps://redis.io/docs/latest/commands/ping/
KEYShttps://redis.io/docs/latest/commands/keys/
SEThttps://redis.io/docs/latest/commands/set/
GEThttps://redis.io/docs/latest/commands/get/
DELhttps://redis.io/docs/latest/commands/del/
variable number of argumentshttps://realpython.com/python-kwargs-and-args/
TCP connectionhttps://en.wikipedia.org/wiki/Transmission_Control_Protocol
context managerhttps://realpython.com/python-with-statement/
pattern matchinghttps://realpython.com/structural-pattern-matching/
Nonehttps://realpython.com/null-in-python/
recursivelyhttps://realpython.com/python-recursion/
Dockerhttps://realpython.com/docker-continuous-integration/
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-bytes/#serialize-python-objects-using-a-binary-format
picklehttps://realpython.com/python-pickle-module/
data serialization in Pythonhttps://realpython.com/python-serialize-data/
https://realpython.com/python-bytes/#manipulate-pixel-data-to-conceal-a-hidden-message
https://files.realpython.com/media/bird_eyes.d044f56893f6.png
last sectionhttps://realpython.com/python-bitwise-operators/#least-significant-bit-steganography
https://realpython.com/python-bytes/#embed-an-image-in-markdown-using-base64
Markdownhttps://realpython.com/django-markdown/
README fileshttps://realpython.com/readme-python-project/
base64https://docs.python.org/3/library/base64.html
https://realpython.com/python-bytes/#compile-and-execute-python-bytecode
opcodeshttps://en.wikipedia.org/wiki/Opcode
AIhttps://realpython.com/chatgpt-coding-mentor-python/
__pycache__ folderhttps://realpython.com/python-pycache/
https://realpython.com/python-bytes/#conclusion
input/output (I/O)https://realpython.com/ref/glossary/input-output/
Click here to download the free sample codehttps://realpython.com/bonus/python-bytes-code/
https://realpython.com/python-bytes/#frequently-asked-questions
https://realpython.com/quizzes/python-bytes/
Python Byteshttps://realpython.com/quizzes/python-bytes/
https://realpython.com/feedback/survey/article/python-bytes/liked/?from=article-footer
https://realpython.com/feedback/survey/article/python-bytes/disliked/?from=article-footer
https://realpython.com/team/bzaczynski/
» More about Bartoszhttps://realpython.com/team/bzaczynski/
https://realpython.com/team/asantos/
Aldrenhttps://realpython.com/team/asantos/
https://realpython.com/team/bweleschuk/
Brendahttps://realpython.com/team/bweleschuk/
https://realpython.com/team/gahjelle/
Geir Arnehttps://realpython.com/team/gahjelle/
https://realpython.com/team/lpozoramos/
Leodanishttps://realpython.com/team/lpozoramos/
https://realpython.com/team/sgruppetta/
Stephenhttps://realpython.com/team/sgruppetta/
Level Up Your Python Skills »https://realpython.com/account/join/?utm_source=rp_article_footer&utm_content=python-bytes
Level Up Your Python Skills »https://realpython.com/account/join/?utm_source=rp_article_footer&utm_content=python-bytes
https://realpython.com/feedback/survey/article/python-bytes/liked/?from=article-comments
https://realpython.com/feedback/survey/article/python-bytes/disliked/?from=article-comments
LinkedInhttps://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Frealpython.com%2Fpython-bytes%2F
Twitterhttps://twitter.com/intent/tweet/?text=Interesting%20Python%20article%20on%20%40realpython%3A%20Bytes%20Objects%3A%20Handling%20Binary%20Data%20in%20Python&url=https%3A%2F%2Frealpython.com%2Fpython-bytes%2F
Blueskyhttps://bsky.app/intent/compose?text=Interesting%20Python%20article%20on%20%40realpython.com%3A%20Bytes%20Objects%3A%20Handling%20Binary%20Data%20in%20Python%20https%3A%2F%2Frealpython.com%2Fpython-bytes%2F
Facebookhttps://facebook.com/sharer/sharer.php?u=https%3A%2F%2Frealpython.com%2Fpython-bytes%2F
Get tips for asking good questionshttps://realpython.com/python-beginner-tips/#tip-9-ask-good-questions
get answers to common questions in our support portalhttps://support.realpython.com
Real Python Community Chathttps://realpython.com/community/
“Office Hours” Live Q&A Sessionhttps://realpython.com/office-hours/
intermediatehttps://realpython.com/tutorials/intermediate/
pythonhttps://realpython.com/tutorials/python/
Python's Bytearray: A Mutable Sequence of Byteshttps://realpython.com/python-bytearray/?utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=python-bytes
Bitwise Operators in Pythonhttps://realpython.com/python-bitwise-operators/?utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=python-bytes
Learn From 2025's Most Popular Python Tutorials and Courseshttps://realpython.com/popular-python-tutorials-2025/?utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=python-bytes
How to Convert Bytes to Strings in Pythonhttps://realpython.com/convert-python-bytes-to-strings/?utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=python-bytes
Structural Pattern Matching in Pythonhttps://realpython.com/structural-pattern-matching/?utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=python-bytes
https://realpython.com/account/signup/?intent=continue_reading&utm_source=rp&utm_medium=web&utm_campaign=rwn&utm_content=v1&next=%2Fpython-bytes%2F
Continue »https://realpython.com/account/signup/?intent=continue_reading&utm_source=rp&utm_medium=web&utm_campaign=rwn&utm_content=v1&next=%2Fpython-bytes%2F
Sign-Inhttps://realpython.com/account/login/?next=/python-bytes/
Start Herehttps://realpython.com/start-here/
Learning Resourceshttps://realpython.com/search
Code Mentorhttps://realpython.com/mentor/
Python Referencehttps://realpython.com/ref/
Python Cheat Sheethttps://realpython.com/cheatsheets/python/
Support Centerhttps://support.realpython.com/
Learning Pathshttps://realpython.com/learning-paths/
Quizzes & Exerciseshttps://realpython.com/quizzes/
Browse Topicshttps://realpython.com/tutorials/all/
Live Courseshttps://realpython.com/live/
Bookshttps://realpython.com/books/
Podcasthttps://realpython.com/podcasts/rpp/
Newsletterhttps://realpython.com/newsletter/
Community Chathttps://realpython.com/community/
Office Hourshttps://realpython.com/office-hours/
Learner Storieshttps://realpython.com/learner-stories/
Plans & Pricinghttps://realpython.com/account/join/
Team Planshttps://realpython.com/account/join-team/
For Businesshttps://realpython.com/account/join-team/inquiry/
For Schoolshttps://realpython.com/account/join-team/education-inquiry/
Reviewshttps://realpython.com/learner-stories/
About Ushttps://realpython.com/about/
Teamhttps://realpython.com/team/
Mission & Valueshttps://realpython.com/mission/
Editorial Guidelineshttps://realpython.com/editorial-guidelines/
Sponsorshipshttps://realpython.com/sponsorships/
Careershttps://realpython.workable.com
Press Kithttps://realpython.com/media-kit/
Merchhttps://realpython.com/merch
https://www.youtube.com/realpython
https://x.com/realpython
https://www.linkedin.com/company/realpython-com
https://www.facebook.com/LearnRealPython
https://github.com/realpython/
Privacy Policyhttps://realpython.com/privacy-policy/
Terms of Usehttps://realpython.com/terms/
Securityhttps://realpython.com/security/
Contacthttps://realpython.com/contact/
https://realpython.com/

Viewport: width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover

Robots: max-image-preview:large


URLs of crawlers that visited me.