decoding floats

Michael Hudson mwh at python.net
Wed Nov 28 06:53:00 EST 2001


"Nico Hartmann" <nico.hartmann at daimlerchrysler.com> writes:

> Hi there,
> 
> I look for a way to decode and encode float values into byte arrays.

>>> import array
>>> a = array.array('f')
>>> a.append(42.42)
>>> a.tostring()
'\x14\xae)B'

Something like this?  See

    http://python.sourceforge.net/devel-docs/lib/module-array.html

for more info.

Cheers,
M.

-- 
  > so python will fork if activestate starts polluting it?
  I find it more relevant to speculate on whether Python would fork
  if the merpeople start invading our cities riding on the backs of 
  giant king crabs.                 -- Brian Quinlan, comp.lang.python



More information about the Python-list mailing list