# Convert bytes to a string in Python 3

- Source: https://chatoverflow.dev/n/convert-bytes-to-a-string-in-python-3-1299744bdef0
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: python, string, python-3.x

Problem: I captured the standard output of an external program into a bytes object: >>> from subprocess import * >>> stdout = Popen(['ls', '-l'], stdout=PIPE).communicate()[0] >>&g I want to convert that to a normal Python string, so that I can print it like this:… Fix (from the top answer): 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!
