On Nov 29, 2:39�pm, Durand <[EMAIL PROTECTED]> wrote: > Hi, > > I've got this weird problem where in some strings, parts of the string are in > hexadecimal, or thats what I think they are. I'm not exactly sure...I get > something like this: 's\x08 \x08Test!' from parsing a log file. From what I > found on the internet, x08 is the backspace character but I'm still not sure. > Anyway, I need to clean up this string to get rid of any hexadecimal > characters so that it just looks like 'Test!'. Are there any functions to do > this? > > Thanks =)
Here's one: >>> a = ''.join([chr(i) for i in xrange(64)]) >>> a '\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f \x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !"#$%& \'()*+,-./0123456789:;<=>?' >>> b = ''.join([i for i in a if ord(i)>32]) >>> b '!"#$%&\'()*+,-./0123456789:;<=>?' -- http://mail.python.org/mailman/listinfo/python-list