Name
fromstring
Synopsis
fromstring(data,count=None,typecode=Int)
Returns a one-dimensional array a of shape
(
count
,)
with data copied from the bytes of string
data. When
count is None,
len(
data
)
must be a multiple of
typecode’s item size, and
a’s shape is
(len(
data
)/
a
.itemsize( ),). When count is not
None,
len(
data
)
must be greater than or equal to
count
*
a
.itemsize( ), and fromstring ignores
data’s trailing bytes, if
any.
Together with methods
a
.tostring and
a
.byteswapped (covered
in the following section Section 15.6.7), function
fromstring allows binary input/output of
array objects. When you need to save arrays and
later reload them, and don’t need to use the saved
form in non-Python programs, it’s simpler and faster
to use module cPickle, covered in Chapter 11. Many experienced users prefer to use a
portable self-describing file format such as
netCDF (see http://met-www.cit.cornell.edu/noon/ncmodule.html).
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access