
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
How to convert byte literals to python strings?
To convert byte literals to Python strings, you need to decode the bytes. It can be done using the decode method on the bytes object.
example
>>> b"abcde".decode("utf-8") u'abcde'
You can also map bytes to chr if the bytes represent ASCII encoding as follows −
bytes = [112, 52, 52] print("".join(map(chr, bytes)))
Output
p44
- Related Articles
- Formatted string literals (f-strings) in Python?
- How to convert BLOB to Byte Array in java?
- How to convert Byte Array to Image in java?
- How to convert Image to Byte Array in java?
- How to convert InputStream to byte array in Java?
- How to convert byte array to string in C#?
- Convert byte primitive type to Byte object in Java
- How to convert a PDF to byte array in Java?
- How to convert an object to byte array in java?
- How to convert java bitmap to byte array In android?
- How to convert hex string to byte Array in Java?
- Java Program to convert byte to string
- Java Program to convert string to byte
- Convert byte to String in Java
- How to join two strings to convert to a single string in Python?

Advertisements