Is there a string function to trim all non-ascii characters out of a string

Paul McGuire ptmcg at austin.rr.com
Mon Dec 31 04:53:50 EST 2007


On Dec 31, 2:54 am, abhishek <guptaabhishek1... at gmail.com> wrote:
>
> Use this function --
>
> def omitNonAscii(nstr):
>     sstr=''
>     for r in nstr:
>         if ord(r)<127:
>             sstr+=r
>     return sstr

<Yoda>
Learn the ways of the generator expression you must.
</Yoda>
See Dan Bishop's post.

-- Paul



More information about the Python-list mailing list