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

android - How to save instance state of selected radiobutton on menu -

python 3 IndexError: list index out of range -

IF statement in MySQL trigger -