Question: I want to save `numpy.array` data into XML file, then read it again. following is my code: 

**array to string**

```
arr=numpy.zeros((20))
s = str(arr) 

```

But This way would generate **enter key and '[',']'** characters in the string. 

**string to array**  

I should remove the enter key and '[',']' first. And then use `numpy.fromstring`

But I don't think that's a good way to do that. **And that can't work on 2-D array**

Answer: 
You are mixing two different ways of doing "to string":

```
a = numpy.zeros((20))

```

you can, after stripping newlines and `[]` from it, put `str(a)` in a new `numpy.matrix()` constructor and initialize `numpy.array()` with the returned value:

```
b = numpy.array(numpy.matrix(" ".join(str(a).split()).strip('[]')))

```

or you can combine `numpy.array.tostring()` with `numpy.fromstring()`:

```
c = numpy.fromstring(a.tostring())

```

but mixing and matching like you tried to do does not work.
In addition to dumping the ndarray to a .npy file using [save and load](http://docs.scipy.org/doc/numpy/reference/routines.io.html) and noting the details of that file in your xml, you could create a string with the data as noted by Nils Werner.

Note: you might want to check out [HDF](http://www.h5py.org/) or [pytables](http://www.pytables.org/moin) (which uses hdf).