String Encode in Python
Level 260 keystrokes
This encodes a string to bytes using UTF-8 encoding.
Python code
# Create a normal (Unicode) string1text = "hello"# encode("utf-8") converts the string into a bytes object using UTF-8# For ASCII letters like these, each character becomes one byte2encoded = text.encode("utf-8")# Prints b'hello' (the b prefix marks a bytes object)3print(encoded)Output
b'hello'
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