string / split method on ASCII code?
carsten at uniqsys.com
Wed Mar 12 21:52:43 CET 2008
On Wed, 2008-03-12 at 15:29 -0500, Michael Wieher wrote:
> Hey all,
> I have these annoying textilfes that are delimited by the ASCII char
> for << (only its a single character) and >> (again a single character)
> Their codes are 174 and 175, respectively.
> My datafiles are in the moronic form
Those are decidedly not ASCII codes, since ASCII only goes to 127.
The easiest approach is probably to replace those markers with some
other characters that occurs nowhere else, for example good old NUL, and
then split on that:
line = line.replace(chr(174), "\0")
line = line.replace(chr(175), "\0")
result = line.split("\0")
More information about the Python-list