Decode the bytes
object to produce a string:
>>> b"abcde".decode("utf-8")
'abcde'
The above example assumes that the bytes
object is in UTF-8, because it is a common encoding. However, you should use the encoding your data is actually in!
More Related Contents:
- Finding and counting the frequency of known pairs of words in multiple files [closed]
- How to handle special cases in my Python code?
- Unable to use convert strings into integers for a for loop
- User input integer list [duplicate]
- Best way to convert string to bytes in Python 3?
- How to search and replace text in a file?
- TypeError: a bytes-like object is required, not ‘str’ when writing to a file in Python 3
- Which is the preferred way to concatenate a string in Python?
- How to use string.replace() in python 3.x
- How to convert ‘binary string’ to normal string in Python3?
- How do I format a string using a dictionary in python-3.x?
- What’s the difference between str.isdigit, isnumeric and isdecimal in python?
- Python – difference between two strings
- How to match any string from a list of strings in regular expressions in python?
- How do I change the string representation of a Python class? [duplicate]
- Removing control characters from a string in python
- Safely evaluate simple string equation
- How to print like printf in Python3?
- How to explain the str.maketrans function in Python 3.6?
- Print without b’ prefix for bytes in Python 3
- “TypeError: a bytes-like object is required, not ‘str'” when handling file content in Python 3
- How can I use f-string with a variable, not with a string literal?
- String-based enum in Python
- FutureWarning: The default value of regex will change from True to False in a future version
- How to sort a list of strings in reverse order without using reverse=True parameter?
- Split text after the second occurrence of character
- What is internal representation of string in Python 3.x
- How does str.startswith really work?
- Python: for loop – print on the same line [duplicate]
- Why do I get “TypeError: not all arguments converted during string formatting” trying to substitute a placeholder like {0} using %?