[SOLVED] How can I decompose a list of numbers (ints) to a bigger list of a certain number of bytes using numpy? – Stack Overflow


This Content is from Stack Overflow. Question asked by andyon98

I want to use Numpy in Python to be able to input values into a function (See below).

my_func(Input, Size, byte_type="big") #Big to notate big endian or "little" to notate little endian.
            ** Code in here to answer the question **

#Calling the function. 
test = my_func([50,60], size=2, byte_type="big")

It should print: [0, 50, 0, 60] since the size is 2 and ive inputted 50 and 60.

test = my_func([40, 50, 60], size=4, byte_type=”big”)

Output: [0, 0, 0, 40, 0, 0, 0, 50, 0, 0, 0, 60]

How can I achieve this?


hope it helps

def my_func(Input, Size, byte_type="big"):
for item in Input:
    for i in range(Size-1):
return result

#Calling the function. 
test = my_func([50,60,20,30], Size=4, byte_type="big")

This Question was asked in StackOverflow by andyon98 and Answered by Jeson Pun It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?