In article <ma************ *************** **********@pyth on.org>,
David Pratt <fa*******@east link.ca> wrote:
I am working with a text format that advises to strip any ascii control
characters (0 - 30) as part of parsing data and also the ascii pipe
character (124) from the data. I think many of these characters are
from a different time. Since I have never seen most of these characters
in text I am not sure how these first 30 control characters are all
represented (other than say tab (\t), newline(\n), line return(\r) ) so
what should I do to remove these characters if they are ever
encountered. Many thanks.
Most of those characters are hard to see.
Represent arbitrary characters in a string in hex: "\x00\x01\x 02" or
with chr(n).
If you just want to remove some characters, look into "".translat e().
nullxlate = "".join([chr(n) for n in xrange(256)])
delchars = nullxlate[:31] + chr(124)
outputstr = inputstr.transl ate(nullxlate, delchars)
_______________ _______________ _______________ _______________ ____________
TonyN.:' *firstname*nlsn ews@georgea*las tname*.com
' <http://www.georgeanels on.com/>