Numeric.tostring() ?

Tim Hochberg hochberg at psn.net
Mon May 10 17:18:00 EDT 1999



Tom Lukasiak wrote in message <7h7k9h$dme at cocoa.brown.edu>...
>Hi,
>    I have found that the best way (or maybe the only way) to read a binary
>image into an array is to do something like this:
>
>f = open(filename)
>data = f.read()
>f.close()
>dataArray = Numeric.fromstring(data, Numeric.Int16)
>
>
>However, I run into trouble when I want to convert a Numeric array into a
>data string, so that I could save my array as a binary image file.  This is
>because there is no Numeric.tostring() method.  What is the best way to fix
>this problem?


There is a tostring method on array objects. For example:

dataArray.tostring()

should do what you want.

-tim







More information about the Python-list mailing list