python - Convert a numpy.ndarray to string(or bytes) and convert it back to numpy.ndarray -


i'm having little trouble here,

i'm trying convert numpy.ndarray string, i've done this:

randomarray.tostring() 

it works, i'm wondering if can transform numpy.ndarray.

what's best way this?

i'm using numpy 1.8.1

context: objective send numpy.ndarray message in rabbitmq (pika library)

you can use fromstring() method this:

arr =np.array([1,2,3,4,5,6]) ts = arr.tostring() print np.fromstring(ts,dtype=int)  >>>[1 2 3 4 5 6] 

sorry short answer, not enough points commenting. remember state data types or you'll end in world of pain.


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -