- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHPPhysics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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
Advertisements