Created
September 25, 2023 01:11
-
-
Save sveetch/574cbe2a5d00d2e55f1233eae54b9954 to your computer and use it in GitHub Desktop.
A simple reminder quickcheat about Python encoding and decoding with string and bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In Python 3, this mental model is pretty straight-forward: | |
Encoding is the process of converting a str to a bytes object | |
Decoding is the process of converting a bytes object to a str | |
┏━━━━━━━┓ ┏━━━━━━━┓ | |
┃ ┃ -> encoding -> ┃ ┃ | |
┃ str ┃ ┃ bytes ┃ | |
┃ ┃ <- decoding <- ┃ ┃ | |
┗━━━━━━━┛ ┗━━━━━━━┛ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment