Verfasst: Dienstag 18. Oktober 2005, 09:24
von lala
Vielen Dank für die Antworten erstma. Also, es ist so, ich hab einen Datensatz, der aus floats, integers, characters usw besteht. Das sieht z.B. so aus:
((0.51999998092651367, 2.1579999923706055, 'D', ':', '\\', 'E', 'D', 19392, 30626, 6, 0, 5115, 30623, -16384, 127, 155, 0, 6, 0, -2456, 18, 6313, 30623, -5560, 30626, -2456, '\xbb', '4', 7936, 18, 6076, 30623, 9, 0, 1, 0, 96, 0, 6149, 30623, 96, 0, 10656, 211, -976, 18, 13966, 30624, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00' usw...
Den will ich jetzt mit Hilfe eines Formatcodes packen. Da struct.pack weder Liste noch tuple noch sting annimmt, weiß ich mir nur mit eval(struct.pack(formatstr,datenstr)) zu helfen. Wenn ich die Datendatei öffne wird aus '\xbb' '\\xbb und aus '\x00' '\\x00'. Dann krieg ich aber ne Fehlermeldung von python, da er das nicht mehr als Hexadezimalstelle annimmt.
Habt ihr ne bessere Idee?
Dank.
lala