Bytes Decode in Python

Level 261 keystrokes

This decodes bytes to a string using UTF-8 encoding.

Python code

# The b prefix makes a bytes literal, not a str
1data = b"hello"
# decode("utf-8") interprets the bytes as UTF-8 and returns a str
2decoded = data.decode("utf-8")
# Prints hello, now without the b'' prefix
3print(decoded)

Output

hello
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this Python code and how often they appear.

  • "× 4
  • (× 2
  • )× 2
  • =× 2
  • -× 1
  • .× 1

More Python examples at level 2

← Python typing practice