On 07/08/18 22:32, Evuraan wrote:

>>>> print('\u00b0'+ " F")
> ° F
> 
> Elsewhere, it no longer seem to work:
> 
>  $ python3
> Python 3.5.2 (default, Nov 23 2017, 16:37:01)
> [GCC 5.4.0 20160609] on linux
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import platform
>>>> platform.release()
> '4.4.0-21-generic'
>>>> print('\u00b0'+ " F")
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> UnicodeEncodeError: 'ascii' codec can't encode character '\xb0' in
> position 0: ordinal not in range(128)

To some degree it depends on what you are printing on,
it needs to support unicode. Not all terminals do.

Secondly it needs to be set to unicode for its character
encoding and it appears from the error condition that
yours is set to ascii...

You could try setting

PYTHONIOENCODING="UTF-8"

in your OS shell and see if that helps, but I suspect
there's a better way to deal with it...

PS. You can check the current setting with:

>>> import sys
>>> sys.stdout.encoding

If it says ascii (or anything other than a Unicode setting)
then that's almost certainly your problem.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to