Filtering out non-readable characters

Ross ross at
Tue Jul 19 04:28:31 EDT 2005

On 15 Jul 2005 17:33:39 -0700, "MKoool" <mohan at> wrote:

>I have a file with binary and ascii characters in it.  I massage the
>data and convert it to a more readable format, however it still comes
>up with some binary characters mixed in.  I'd like to write something
>to just replace all non-printable characters with '' (I want to delete
>non-printable characters).
>I am having trouble figuring out an easy python way to do this... is
>the easiest way to just write some regular expression that does
>something like replace [^\p] with ''?
>Or is it better to go through every character and do ord(character),
>check the ascii values?
>What's the easiest way to do something like this?

Easiest way is open the file with EdXor (freeware editor), select all,
Format > Wipe Non-Ascii.

Ok it's not python, but it's the easiest.

More information about the Python-list mailing list