Python program to convert a byte string to a list of integers Last Updated : 16 Jan, 2025 Summarize Suggest changes Share Like Article Like Report We have to convert a byte string to a list of integers extracts the byte values (ASCII codes) from the byte string and stores them as integers in a list. For Example, we are having a byte string s=b"Hello" we need to write a program to convert this string to list of integers so the output should be s=[72,101,108,108,111].Using a Simple list() ConversionByte 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 int_l = list(s) print(int_l) Output[72, 101, 108, 108, 111] Explanation:Variable s is a byte string (b"Hello") where each character is represented by its corresponding byte value.list(s) converts the byte string into a list of integers where each byte is represented by its ASCII value: [72, 101, 108, 108, 111]Using a List ComprehensionWe can also use a list comprehension to iterate over the byte string and get a list of integers. Python # Byte string s = b"Hello" # Convert to a list of integers using list comprehension int_l = [byte for byte in s] print(int_l) Output[72, 101, 108, 108, 111] Explanation:Variable s holds a byte string (b"Hello"), where each character is represented as a byte (ASCII value).List comprehension [byte for byte in s] iterates over the byte string, converting each byte into its integer value and storing them in the list: [72, 101, 108, 108, 111]. Advertise with us Next Article Python | Convert list of numerical string to list of Integers K Kanchan_Ray Follow Similar Reads Python - Convert List of Integers to a List of Strings We are given a list of integers and our task is to convert each integer into its string representation. For example, if we have a list like [1, 2, 3] then the output should be ['1', '2', '3']. In Python, there are multiple ways to do this efficiently, some of them are: using functions like map(), re 3 min read Python Program to Convert a list of multiple integers into a single integer There are times when we need to combine multiple integers from a list into a single integer in Python. This operation is useful where concatenating numeric values is required. In this article, we will explore efficient ways to achieve this in Python.Using join()join() method is the most efficient an 2 min read Python program to convert hex string to decimal Converting a hexadecimal string to a decimal number is a common task in programming, especially when working with binary data or low-level computations. Hexadecimal values offer a concise way to represent large numbers.Using the int() FunctionUsing the int() function is the most common and straightf 2 min read Python | Convert list of numerical string to list of Integers Many times, the data we handle might not be in the desired form for any application and has to go through the stage of preprocessing. One such kind of form can be a number in the form of a string that too is a list in the list and we need to segregate it into digit-separated integers. Let's discuss 5 min read Python - Integers String to Integer List In this article, we will check How we can Convert an Integer String to an Integer List Using split() and map()Using split() and map() will allow us to split a string into individual elements and then apply a function to each element. Pythons = "1 2 3 4 5" # Convert the string to a list of integers u 2 min read Python program to convert Base 4 system to binary number Given a base 4 number N, the task is to write a python program to print its binary equivalent. Conversion Table: Examples: Input : N=11002233 Output : 101000010101111 Explanation : From that conversion table we changed 1 to 01, 2 to 10 ,3 to 11 ,0 to 00.Input : N=321321 Output: 111001111001Method 1: 3 min read Article Tags : Python Python Programs Python list-programs Python string-programs Practice Tags : python Like