pythonpython-2.7python-bytearray

Convert a byte array to string


I have a bunch of numbers in a string array and I feel like they are bunch of bytes.

I wonder how I can convert those numbers into an actual string representation. I guess I need to convert this string array to a byte array and later I can decode this byte array to string.

Any help?


Solution

  • Something like this?

    >>> s = "104,101,108,108,111"
    >>> "".join(chr(int(number)) for number in s.split(","))
    'hello'