By using list() function
The list() function is used to create a list from the specified iterable taken as its parameter.
Syntax:
list([iterable])
Parameters: This function accepts a single parameter that is illustrated below:
- iterable: This is the specified sequence that is going to be created as another list.
Return values: This function returns a new list created out of the given iterable passed as its arguments.
Example: Python program to a byte string to a list of integers
Python3
# Python program to illustrate the # conversion of a byte string # to a list of integers # Initializing a byte string as GFG x = b 'GFG' # Calling the list() function to # create a new list of integers that # are the ascii values of the byte # string GFG print ( list (x)) |
Output:
[71, 70, 71]
Time Complexity: O(n)
Space Complexity: O(n)
Python program to convert a byte string to a list of integers
Given a byte string. The task is to write a Python program to convert this byte of string to a list of integers.
Contact Us