non printable (moving away from Perl)

MRAB python at mrabarnett.plus.com
Fri Mar 11 14:23:54 EST 2016


On 2016-03-11 00:07, Fillmore wrote:
>
> Here's another handy Perl regex which I am not sure how to translate to
> Python.
>
> I use it to avoid processing lines that contain funny chars...
>
> if ($string =~ /[^[:print:]]/) {next OUTER;}
>
> :)
>
Python 3 (Unicode) strings have an .isprintable method:

mystring.isprintable()




More information about the Python-list mailing list