How to convert a b string to a string in Python

A string prefixed with b or B represents a bytes literal, and may only contain ASCII characters; bytes with a numeric value of 128 or greater must be expressed with escapes. Converting a byte literal to a string results in a string literal with the same characters as the bytes literal.

Solution for How to convert a b string to a string in Python : You can use bytes.decode() to convert a b string to a string Call bytes.decode(encoding) with encoding as the encoding the bytes literal is in to convert the bytes literal to a string literal. By default, encoding is set to “utf-8”.


how-to-convert-a-b-string-to-a-string-in-python