How to get ° character in a string in python?

前端 未结 6 1079
南方客
南方客 2020-12-07 16:07

How can I get a ° (degree) character into a string?

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-07 16:43

    >>> u"\u00b0"
    u'\xb0'
    >>> print _
    °
    

    BTW, all I did was search "unicode degree" on Google. This brings up two results: "Degree sign U+00B0" and "Degree Celsius U+2103", which are actually different:

    >>> u"\u2103"
    u'\u2103'
    >>> print _
    ℃
    

提交回复
热议问题