[Tutor] pythonic ascii decoding!
eryk sun
eryksun at gmail.com
Mon Jul 31 19:13:51 EDT 2017
On Mon, Jul 31, 2017 at 3:39 PM, bruce <badouglas at gmail.com> wrote:
>
> So, is there a quick/dirty approach I can use to simply strip out the
> "non-ascii" chars. I know, this might not be the "best/pythonic" way,
> and that it might result in loss of some data/chars, but I can live
> with it for now.
Ignore or replace the non-ASCII characters. For example:
>>> print 's\xffp\xffa\xffm'.decode('ascii', 'ignore')
spam
>>> print 's\xffp\xffa\xffm'.decode('ascii', 'replace')
s�p�a�m
More information about the Tutor
mailing list