Home > Mobile >  How to create a dictionary from arrays in Python
How to create a dictionary from arrays in Python

Time:10-02

How to create a dictionary exactly like this: Don't worry about contents.

 {'image': array([[[238, 238, 239, ..., 226, 227, 230],
     [234, 238, 240, ..., 226, 227, 225],
     [255, 255, 255, ..., 255, 255, 255]],
     ...,
     [255, 255, 255, ..., 255, 255, 255],
     [255, 255, 255, ..., 255, 255, 255],
     [255, 255, 255, ..., 255, 255, 255]]], dtype=uint8)

CodePudding user response:

my_dict = {'image': np.array([[[238...]]])}

CodePudding user response:

You can use something like this to work on:

dict(zip(keys, zip(*array)))

CodePudding user response:

array = [[[1,2],[2,3]],[[1]]]
data = {"image": array}
  • Related