[Tutor] pythonic ascii decoding!

bruce badouglas at gmail.com
Mon Jul 31 11:39:46 EDT 2017


Hi guys.

Testing getting data from a number of different US based/targeted
websites. So the input data source for the most part, will be "ascii".
I'm getting a few "weird" chars every now and then asn as fas as I can
tell, they should be utf-8.

However, the following hasn;t always worked:
    s=str(s).decode('utf-8').strip()

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.

thoughts/comments ??

thanks


More information about the Tutor mailing list