UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in position 13: ordinal not in range(128)

Piet van Oostrum piet at cs.uu.nl
Thu Jul 16 18:08:08 EDT 2009

>>>>> akhil1988 <akhilanger at gmail.com> (a) wrote:

>a> ok!
>a> I got the indentation errors fixed. Bu I get another error:

>a> Traceback (most recent call last):
>a>   File "./temp.py", line 484, in <module>
>a>     main()
>a>   File "./temp.py", line 476, in main
>a>     line.decode('utf-8').strip()
>a> AttributeError: 'str' object has no attribute 'decode'

>a> I am using Python3.1

In Python 3 you can't decode strings because they are Unicode strings
and it doesn't make sense to decode a Unicode string. You can only
decode encoded things which are byte strings. So you are mixing up byte
strings and Unicode strings.
Piet van Oostrum <piet at cs.uu.nl>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: piet at vanoostrum.org

More information about the Python-list mailing list