Skip to content

Instantly share code, notes, and snippets.

@moulik-source
Created June 2, 2023 16:53
Show Gist options
  • Save moulik-source/a6429a46201c822f456e2e441b3ed0f6 to your computer and use it in GitHub Desktop.
Save moulik-source/a6429a46201c822f456e2e441b3ed0f6 to your computer and use it in GitHub Desktop.
my_byte = b'Hello'
my_string = my_byte.decode('utf-8') # converts bytes to a string using UTF-8 encoding
print(my_string) # 'Hello'
new_byte = my_string.encode('utf-8') # converts the string back to bytes using UTF-8 encoding
print(new_byte) # b'Hello'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment