Real Python
  • Start Here
  • Learn Python
    Python Tutorials →
    In-depth articles and video courses
    Learning Paths →
    Guided study plans for accelerated learning
    Quizzes & Exercises →
    Check your learning progress
    Browse Topics →
    Focus on a specific area or skill level
    Community Chat →
    Learn with other Pythonistas
    Office Hours →
    Live Q&A calls with Python experts
    Podcast →
    Hear what’s new in the world of Python
    Books →
    Round out your knowledge and learn offline
    Reference →
    Concise definitions for common Python terms
    Code Mentor →Beta
    Personalized code assistance & learning tools
    Unlock All Content →
  • More
    Learner Stories Python Newsletter Python Job Board Meet the Team Become a Tutorial Writer Become a Video Instructor
  • Search
/
  • Join
  • Sign‑In

— FREE Email Series —

🐍 Python Tricks 💌

Python Tricks Dictionary Merge

🔒 No spam. Unsubscribe any time.

Browse Topics Guided Learning Paths
Basics Intermediate Advanced
ai algorithms api best-practices career community databases data-science data-structures data-viz devops django docker editors flask front-end gamedev gui machine-learning news numpy projects python stdlib testing tools web-dev web-scraping

Table of Contents

  • Brushing Up on Binary Fundamentals
    • Bits, Bytes, and Binary Data
    • Binary Words and Endianness
    • Signedness and the Sign Bit
    • Two’s Complement vs Python
  • Getting to Know the bytes Object in Python
    • Bytes-Like Objects and bytes
    • Python’s Buffer Protocol
  • Creating Python bytes by Hand
    • The Bytes Literal Format
    • The Built-in bytes() Function
    • The bytes.fromhex() Class Method
  • Manipulating Bytes Objects in Python
    • Use bytes Like a Python String
    • Convert Between Bytes and Strings
    • Represent Bytes in Python Differently
  • Working With Python Bytes in Practice
    • Read and Write Binary Files of Varying Sizes
    • Communicate Over a Binary Network Protocol
    • Serialize Python Objects Using a Binary Format
    • Manipulate Pixel Data to Conceal a Hidden Message
    • Embed an Image in Markdown Using Base64
    • Compile and Execute Python Bytecode
  • Conclusion
  • Frequently Asked Questions