Re: Problem with __str__ method and character encoding

Discussion in 'Python' started by Chris Angelico, Dec 7, 2012.

  1. On Sat, Dec 8, 2012 at 1:14 AM, gialloporpora <> wrote:
    >>>> print a

    > UnicodeError
    >>>> print a.__str__()

    > OK


    By the way, it's *much* more helpful to copy and paste the actual
    error message and output, rather than retyping like that. Spending one
    extra minute in the interactive interpreter before you post can save
    us all a lot of time and confusion. In this case, what I'm seeing is
    (Python 2.6):

    >>> print a


    Traceback (most recent call last):
    File "<pyshell#19>", line 1, in <module>
    print a
    UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in
    position 27: ordinal not in range(128)

    Which has quite a bit of handy information in it.

    ChrisA
    Chris Angelico, Dec 7, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeffrey E. Forcier
    Replies:
    7
    Views:
    319
    Christopher Subich
    Jul 24, 2005
  2. Jeffrey E. Forcier
    Replies:
    2
    Views:
    317
    Jeffrey E. Forcier
    Jul 24, 2005
  3. [david]
    Replies:
    6
    Views:
    305
    John Machin
    Sep 13, 2007
  4. netimen
    Replies:
    5
    Views:
    264
    Steven D'Aprano
    Oct 23, 2008
  5. peter
    Replies:
    0
    Views:
    128
    peter
    Dec 7, 2012
Loading...

Share This Page