ascii problem

Skip Montanaro skip at pobox.com
Mon Aug 11 21:20:43 CEST 2003


    >>> a = "andré"
    UnicodeError: ASCII encoding error: ordinal not in range(128)

Use Unicode:

    >>> a = unicode("andr\xe9", "iso-8859-1")
    >>> print a.encode("iso-8859-1")
    andré

With a Euro keyboard you won't have to embed hex codes in your strings.

Skip





More information about the Python-list mailing list