Pound sign problem

Steve D'Aprano steve+python at pearwood.info
Mon Apr 10 21:30:04 EDT 2017


On 2017年4月11日 12:50 am, Lew Pitcher wrote:
> David Shi wrote:
>>> In the data set, pound sign escape appears:
>> u'price_currency': u'\xa3', u'price_formatted': u'\xa3525,000',

That looks like David is using Python 2.
>> When using table.to_csv after importing pandas as pd, an error message
>> persists as follows: UnicodeEncodeError: 'ascii' codec can't encode
>> character u'\xa3' in position 0: ordinal not in range(128)
>> There is no "pound sign" in ASCII[1]. Try changing your target encoding to
> something other than ASCII.

Please don't encourage the use of old legacy encodings.
In 2017, unless you are reading from old legacy files created using a
non-Unicode encoding, you should just use UTF-8.
-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /