How to get a unicode degrees symbol?
Russell E. Owen
owen at astrono.junkwashington.emu
Thu Jun 7 14:17:54 EDT 2001
>> OK, but surely there must be some simple way to do this that doesn't
>> require a big case statement (if platform x then use encoding y...)
>> and knowing the name of the most appropriate encoding for each
>> platform?
>
>Indeed there is, the code
>
>>>> import Tkinter
>>>> l=Tkinter.Label(text=u"\N{DEGREE SIGN}")
>>>> l.pack()
>
>should work on every system (provided a Tk port and proper fonts are
>available).
Thank! I'll try it! The interpreter shows it as u'\xb0' and str() raises
an exception, so I didn't even try it in Tk, assuming I'd get a similar
mess. I would prefer an entity that would work in more instances (such
as printing to the log window), but Tk is by far the most important
thing. If it works, as I assume it will, I'll switch from my current
messy case satetement.
-- Russell
More information about the Python-list
mailing list