Save & Retrieve Numpy Array From String

后端 未结 2 738
孤独总比滥情好
孤独总比滥情好 2021-01-06 06:55

I would like to convert a multi-dimensional Numpy array into a string and, later, convert that string back into an equivalent Numpy array.

I do not want to save the

2条回答
  •  一向
    一向 (楼主)
    2021-01-06 07:41

    If you want to save the dtype as well you can also use the pickle module from python.

    import pickle
    import numpy as np
    
    a = np.ones(4)
    string = pickle.dumps(a)
    pickle.loads(string)
    

提交回复
热议问题