Help: python unicode
low kian seong
kianseong.low at logisticsconsulting.asia
Fri Feb 18 01:32:49 EST 2011
On Fri, Feb 18, 2011 at 11:40 AM, tom z <maillist.tom at gmail.com> wrote:
> Hi all~
> My script can't work.I've changed my defaultencoding from 'ascii' to
> 'utf-8',but Python also raises a 'UnicodeEncodeError' error.
>
> the error likes this:
>
> >>> s=u'La Pe\xf1a'
> >>>print s
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xf1' in
> position 5: ...
>
>>> s=u'La Pe\xf1a'
>>> print s.encode('utf-8')
La Peña
? or use smart_str from django ?
By the way did you lift that example from Dive Into Python ?
>
> And in my script, there're many 'print' statements.So SOS~~~~
> what should i do???
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
--
Low Kian Seong
Senior Software Manager
Logistics Consulting Asia
M: +6 012 3736874 • T: +60 3 7729 9386 • F: +60 3 7729 7386
www.logisticsconsulting.asia
China • India • Indonesia • Malaysia • Philippines • Singapore •
Thailand • Vietnam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110218/d8b73932/attachment-0001.html>
More information about the Python-list
mailing list