[Tutor] python3 - °F/°C printing those degree signs

Evuraan evuraan at gmail.com
Tue Aug 7 17:32:58 EDT 2018


Greetings!  How to print °F/°C etc in python3?


(This works on a WSL):

~$ python3
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform
>>> platform.release()
'4.4.0-17134-Microsoft'
>>> 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)


How can we print °F / °C etc. - that should work everywhere on python3
so I can use the same code?

Thanks in advance!


More information about the Tutor mailing list