
Hallo Liste, ich habe folgende Zeichenkette in einem Binärfile): '\x01\x93' Wie bekomme ich diese Zeichenkette mit den Hexwerten so umgewandelt, dass anschließen der Int Wert (oder auch String) 193 rauskommt? Viele Grüße Andreas -- vocote.de e.K. :: Programmierung - Internet - Beratung Tel. 03741 222301 :: mobil 0172 3446687 :: akaiser@vocote.de _______________________________________________ python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Andreas Kaiser schrieb:
Was soll da rauskommen? *ungläubig schau* Du möchtest 2 Bytes lesen und diese in Hex-Darstellung ausgeben? Little oder big endian? Anscheinend big.
Besser wäre aber wohl, das Byteweise zu machen. - -- Schönen Gruß - Regards Hartmut Goebel | Hartmut Goebel | IT-Security -- effizient | | h.goebel@goebel-consult.de | www.goebel-consult.de | -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) Comment: Using GnuPG with Mandriva - http://enigmail.mozdev.org iQEVAwUBRLZdw8zajR0mSa83AQJQjQf+NKN3F4eVMCI7U9os/aWZJufqznSsvERo 40eKm3kEk5JX7GtP31TcAIQillAHsXhvizXi+YotUSp2OWsiSDEknx6YnO0lDrMB xzAQAUtnWh9Gsjxp8UDkTbO9O6dHOMMwEKXwiXeDcZLJ8PMKoOPfUHa+X78RFXXu QBM1/E9pW4XjDzk+rA764wA1ONjFghhfM6/FSOugYev3p1Jgm7nf0gT3fhe3WuIm pKW1RDVrZOh4pKCusfOrLYuKrPh8mwy/DVJ2SgQ0fpNQzLVk5jnra91T8QzvwPXJ YStwLSaydB0nSpCD1UQC4QOSEChEt7oFQV1wbI7YqBtXr6RPwjCSbQ== =IY7M -----END PGP SIGNATURE----- _______________________________________________ python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de

Hallo Hartmut, Hartmut Goebel schrieb:
_______________________________________________ python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de

Andreas Kaiser wrote:
Ich stelle mal eine andere Theorie als Hartmut auf, wie genau die Konvertierung laufen soll. Es könnte sich um BCD-Kodierung handeln (Binary Coded Decimals), wo jedes Byte zwei Dezimalziffern kodiert. Hier ein Vorschlag: erstelle eine Tabelle, die jedes Byte in eine Zahl 0..100 umwandelt, und iteriere dann über die Bytes: table = [None]*256 for x in range(10): for y in range(10): table[16*x+y] = 10*x+y def convert(bytes): result = 0 for b in bytes: result = result*100 + table[ord(b)] return result Ciao, Martin _______________________________________________ python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Andreas Kaiser schrieb:
Was soll da rauskommen? *ungläubig schau* Du möchtest 2 Bytes lesen und diese in Hex-Darstellung ausgeben? Little oder big endian? Anscheinend big.
Besser wäre aber wohl, das Byteweise zu machen. - -- Schönen Gruß - Regards Hartmut Goebel | Hartmut Goebel | IT-Security -- effizient | | h.goebel@goebel-consult.de | www.goebel-consult.de | -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) Comment: Using GnuPG with Mandriva - http://enigmail.mozdev.org iQEVAwUBRLZdw8zajR0mSa83AQJQjQf+NKN3F4eVMCI7U9os/aWZJufqznSsvERo 40eKm3kEk5JX7GtP31TcAIQillAHsXhvizXi+YotUSp2OWsiSDEknx6YnO0lDrMB xzAQAUtnWh9Gsjxp8UDkTbO9O6dHOMMwEKXwiXeDcZLJ8PMKoOPfUHa+X78RFXXu QBM1/E9pW4XjDzk+rA764wA1ONjFghhfM6/FSOugYev3p1Jgm7nf0gT3fhe3WuIm pKW1RDVrZOh4pKCusfOrLYuKrPh8mwy/DVJ2SgQ0fpNQzLVk5jnra91T8QzvwPXJ YStwLSaydB0nSpCD1UQC4QOSEChEt7oFQV1wbI7YqBtXr6RPwjCSbQ== =IY7M -----END PGP SIGNATURE----- _______________________________________________ python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de

Hallo Hartmut, Hartmut Goebel schrieb:
_______________________________________________ python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de

Andreas Kaiser wrote:
Ich stelle mal eine andere Theorie als Hartmut auf, wie genau die Konvertierung laufen soll. Es könnte sich um BCD-Kodierung handeln (Binary Coded Decimals), wo jedes Byte zwei Dezimalziffern kodiert. Hier ein Vorschlag: erstelle eine Tabelle, die jedes Byte in eine Zahl 0..100 umwandelt, und iteriere dann über die Bytes: table = [None]*256 for x in range(10): for y in range(10): table[16*x+y] = 10*x+y def convert(bytes): result = 0 for b in bytes: result = result*100 + table[ord(b)] return result Ciao, Martin _______________________________________________ python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de
participants (3)
-
"Martin v. Löwis"
-
Andreas Kaiser
-
Hartmut Goebel