How do I convert a Python 3 byte-string variable into a regular string?
I have read in an XML email attachment with bytes_string=part.get_payload(decode=False) The payload comes in as a byte string, as my variable name suggests. I am trying to use the recommended Python 3 approach to turn this string into a usable string that I can manipulate. The example shows: str(b'abc','utf-8') How can I apply the b (bytes) keyword argument to my variable bytes_string and use the recommended approach? The way I tried doesn't work: str(bbytes_string, 'utf-8') Toby Speight You had it nearly right in the last line. You want str(bytes_string, 'utf-8') because the type of bytes