[Python-de] Zeichen in Zahlen umwandeln

Georg Brandl g.brandl at gmx.net
So Jun 22 11:00:59 CEST 2008


Wagner, Frank schrieb:
> Hallo,
> 
> ich beschäftige mich seit kurzer Zeit etwas mit Python und lese nun Daten
> seriell von einem Gerät aus. Leider ist diese Schnittstelle nicht
> Zeichenorientier sondern es komme direkt die Messwerte im float Format über
> die Schnittstelle. Ich erhalte somit eine Zeichenkette die wie folgt
> aussieht: ['\xaa\xaa\x00\x10$\xbf\x00\x9c`A\xfd\xd0']
> 
> In C würde ich irgend sowas wie atoi versuchen anzuwenden aber in Python hab
> ich bisher nichts gefunden und hoffe nun dass mir jemand aus der Liste
> weiterhelfen kann?

Für so etwas benutzt man in Python das ``struct``-Modul.

Georg

-- 
Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
Four shall be the number of spaces thou shalt indent, and the number of thy
indenting shall be four. Eight shalt thou not indent, nor either indent thou
two, excepting that thou then proceed to four. Tabs are right out.





Mehr Informationen über die Mailingliste python-de