ascii character - removing chars from string
bruce
bedouglas at earthlink.net
Mon Jul 3 21:27:09 EDT 2006
hi...
update. i'm getting back html, and i'm getting strings like " foo "
which is valid HTML as the ' ' is a space.
i need a way of stripping/removing the ' ' from the string
the needs to be treated as a single char...
text = "foo cat "
ie ok_text = strip(text)
ok_text = "foo cat"
thanks
-bruce
-----Original Message-----
From: python-list-bounces+bedouglas=earthlink.net at python.org
[mailto:python-list-bounces+bedouglas=earthlink.net at python.org]On Behalf
Of Rune Strand
Sent: Monday, July 03, 2006 5:43 PM
To: python-list at python.org
Subject: Re: ascii character - removing chars from string
bruce wrote:
> hi...
>
> i'm running into a problem where i'm seeing non-ascii chars in the parsing
> i'm doing. in looking through various docs, i can't find functions to
> remove/restrict strings to valid ascii chars.
>
> i'm assuming python has something like
>
> valid_str = strip(invalid_str)
>
> where 'strip' removes/strips out the invalid chars...
>
> any ideas/thoughts/pointers...
If you're able to define the invalid_chars, the most convenient is
probably to use the strip() method:
>>> a_string = "abcdef"
>>> invalid_chars = 'abc'
>>> a_string.strip(invalid_chars)
'def'
--
http://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list