sorry for this stupid question about struct module

jepler at unpythonic.net jepler at unpythonic.net
Thu Sep 19 18:19:53 EDT 2002


>>> '\x00\x00\x00\n' == '\x00\x00\x00\x0A'
True
'\x00\x00\x00\n'

Ascii code 10 is repr()'d as \n.

If you don't like this, you could use a different function to print the
quoted value of a string:

>>> quote = lambda s: "'" + "".join(["\\x%02x" % ord(c) for c in s]) + "'"
>>> print quote("\0\0\0\n")
'\x00\x00\x00\x0a'

Jeff




More information about the Python-list mailing list