You can pass the bytes string into list() to convert back:

>>> lst = [1, 2, 3, 4, 5]
>>> bytes(lst)
b'\x01\x02\x03\x04\x05'
>>> list(bytes(lst))
[1, 2, 3, 4, 5]
Answer from ggorlen on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org β€Ί python-program-to-convert-a-byte-string-to-a-list-of-integers
Python program to convert a byte string to a list of integers - GeeksforGeeks
January 16, 2025 - Byte string is already a sequence of integers (where each byte is an integer between 0 and 255) we can directly convert the byte string to a list of integers using list(). Python Β· # Byte string s = b"Hello" # Convert to a list of integers ...
🌐
Finxter
blog.finxter.com β€Ί home β€Ί learn python blog β€Ί 5 best ways to convert python bytes to list
5 Best Ways to Convert Python Bytes to List - Be on the Right Side of Change
February 23, 2024 - The built-in list() constructor can convert iterable objects into a list easily. This method is very straightforward and requires only a single function call to transform the bytes object into a list of integers.
Discussions

How to get back a list from bytes in Python? - Stack Overflow
I have a list in Python that I converted to bytes using bytes(). I want to get back that list and I am unsure how to do that. I searched around and it seemed to me like I can get back integers or s... More on stackoverflow.com
🌐 stackoverflow.com
Lists to Bytes
Encoding each string to a bytes string? >>> list_of_items_bytes = [bytes(s, 'utf-8') for s in list_of_items] >>> list_of_items_bytes [b'Cats', b'Dogs', b'Turtle', b'Humans'] More on reddit.com
🌐 r/learnpython
8
4
April 26, 2021
python - Convert bytes into list - Stack Overflow
So I have this variable with some bytes in it (not sure if that's the right name.) data = b'red\x00XY\x001\x00168.93\x00859.07\x00' I need to convert this to a list. The intended output would be something like. More on stackoverflow.com
🌐 stackoverflow.com
arrays - allocating a bytes list in Python - Stack Overflow
Stack Overflow chat opening up to all users in January; Stack Exchange chat... ... 3 In python 3, how can I put individual bytes from a bytes object into a list without them being converted to integers? More on stackoverflow.com
🌐 stackoverflow.com
🌐
Reddit
reddit.com β€Ί r/learnpython β€Ί how do i convert a list to a byte-like object?
r/learnpython on Reddit: How Do I Convert a List to a Byte-Like Object?
July 19, 2021 -

I am trying to pass a list to an OS command using subprocess.communicate, but can't seem to get it to use my list. I did some researching and thought I was supposed to use bytes to convert my list to a byte-like object, but bytes does not take lists. I am very new to Python and having a hard time figuring this out. My functions is:

def prompt_for_input(list_of_programs, prompt_menu, extra_arguments, prompt_string):
    ## Variable declarations.
    user_selection = None

    ## If extra_arguments were passed, then reform  prompt_menu
    ## to contain the extra_arguments.
    if extra_arguments:
            ## Get the prompt argument from prompt_menu.
            prompt_argument = "-" + prompt_menu.split('-')[1]

            ## Reform prompt_menu to include extra_arguments.
            prompt_argument_index = prompt_menu.index(prompt_argument)
            prompt_menu = prompt_menu[:prompt_argument_index] + extra_arguments +\
                  " " + prompt_menu[prompt_argument_index:]

    ## Add prompt_string to prompt_menu.
    prompt_menu = prompt_menu + " " + prompt_string

    ## Get the user_selection.
    process = subprocess.Popen(shlex.split(prompt_menu), stdout=subprocess.PIPE,\
                           stdin=subprocess.PIPE)

    user_selection = process.communicate(input=bytes(list_of_programs))

I can't seem to find any solid information on how to convert this, could someone point me in the right direction?

Edit

  • Updated the code above to match with master.

🌐
w3resource
w3resource.com β€Ί python-exercises β€Ί python-basic-exercise-94.php
Python: Convert a byte string to a list of integers - w3resource
May 17, 2025 - # Create a bytes object containing ... and print the result. print("Convert bytes of the said string to a list of integers:") print(list(x)) # Print an empty line for clarity....
🌐
TutorialsPoint
tutorialspoint.com β€Ί article β€Ί python-program-to-convert-a-byte-string-to-a-list
Python Program to Convert a Byte String to a List
March 27, 2026 - Use list() for direct byte string conversion, or list comprehension for more complex transformations. The ord() function is useful when working with regular strings to get ASCII values.
🌐
Python Forum
python-forum.io β€Ί thread-32560.html
Convert Bytearray into List using list()
Following is code for creating list from bytearray with proper indexing using list: P.S.: Code can be small but I have inserted debug statements like print(), type(), etc. for understanding purpose my_list = b'[1, 0, 1, 1]' my_list_conv = list(my...
Find elsewhere
🌐
Reddit
reddit.com β€Ί r/learnpython β€Ί lists to bytes
r/learnpython on Reddit: Lists to Bytes
April 26, 2021 -

I am trying to convert a list into data-type bytes so I can encrypt it. Anyone knows how to do it for a list with strings. Thanks

Here's a example:

list_of_items = ["Cats", "Dogs","Turtle","Humans"]

list_of_items_byte = bytes(list_of_items,"utc-8")

and I get this error:

File "main.py", line 2, in <module>

list_of_items_byte = bytes(list_of_items,"utc-8")

TypeError: encoding without a string argument

🌐
Python
docs.python.org β€Ί 3 β€Ί builtins β€Ί stdtypes.html
Built-in Types β€” Python 3.14.7 documentation
While the in and not in operations are used only for simple containment testing in the general case, some specialised sequences (such as str, bytes and bytearray) also use them for subsequence testing: ... Values of n less than 0 are treated as 0 (which yields an empty sequence of the same type as s). Note that items in the sequence s are not copied; they are referenced multiple times. This often haunts new Python programmers; consider: >>> lists = [[]] * 3 >>> lists [[], [], []] >>> lists[0].append(3) >>> lists [[3], [3], [3]]
🌐
Python
docs.python.org β€Ί 3.1 β€Ί library β€Ί stdtypes.html
5. Built-in Types β€” Python v3.1.5 documentation
September 6, 2021 - That means that for a bytes or ... (b'...') since it is generally more useful than e.g. bytes([50, 19, 100]). You can always convert a bytes object into a list of integers using list(b). Also, while in previous Python versions, byte strings and Unicode strings could be ...
🌐
Dot Net Perls
dotnetperls.com β€Ί bytes-python
Python - bytes, bytearray Examples - Dot Net Perls
We can use the bytearray built-in, and pass it a list instance to create a bytearray.
🌐
w3resource
w3resource.com β€Ί python β€Ί python-bytes.php
Python Bytes, Bytearray
#create a bytes object y = b'Python bytes' #generates a list of codes from the characters of bytes z = list(y) print(z)
🌐
Real Python
realpython.com β€Ί python-bytes
Bytes Objects: Handling Binary Data in Python – Real Python
March 5, 2025 - To reveal the numeric values behind those bytes, you can convert your bytes object to another sequence type, such as a Python list:
🌐
Stack Overflow
stackoverflow.com β€Ί questions β€Ί 30658193 β€Ί how-to-make-a-bytes-object-from-a-list-of-integers-in-python-3
How to make a bytes object from a list of integers in Python 3 - Stack Overflow
I have an array of integers (all less than 255) that correspond to byte values, e.g. [55, 33, 22]. How can I turn that into a bytes object that would look like b'\x55\x33\x22'?
🌐
Python.org
discuss.python.org β€Ί python help
Get single-byte bytes objects from a bytes object - Python Help - Discussions on Python.org
December 22, 2023 - A bytes object yield int values when being iterated over: >>> list(b'abc') [97, 98, 99] I find myself wanting something like this: >>> b'abc'.to_list_of_single_bytes() [b'a', b'b', b'c'] I thought that .split() is th…
🌐
Programiz
programiz.com β€Ί python-programming β€Ί methods β€Ί built-in β€Ί bytes
Python bytes()
Online Python Online JavaScript Online SQL Online Java Online HTML Online C Online C++ Online C# Online PHP Online Swift Online Kotlin Online TypeScript Online Go Online Rust Online Scala Online Dart Online R Online Ruby ... The bytes() method returns an immutable bytes object initialized with the given size and data. ... # convert string to ...