Convert Bytes to String in Python

python_tutorials

Introduction

In this article, we’ll take a look at how to convert Bytes to a String in Python. By the end of this article you will have a clear idea of what these types are and how to effectively handle data using them.

Depending on the version of Python you’re using, this task will differ. Although Python 2 has reached its end of life, many projects still use it, so we’ll include both the Python 2 and Python 3 approaches.

Convert Bytes to String in Python 3

Since Python 3, the old ASCII way of doing things had to go, and Python became completely Unicode.

This means that we lost the explicit unicode type: u"string" – every string is a u"string"!

To differentiate these strings from good old bytestrings, we’re introduced to a new specifier for them – the b"string".

This was added in Python

 

 

To finish reading, please visit source site