Python: Using .format() on a Unicode-escaped string

前端 未结 3 2138
眼角桃花
眼角桃花 2020-12-04 08:46

I am using Python 2.6.5. My code requires the use of the \"more than or equal to\" sign. Here it goes:

>>> s = u\'\\u2265\'
>>> print s
&         


        
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-04 09:21

    unicodes need unicode format strings.

    >>> print u'{0}'.format(s)
    ≥
    

提交回复
热议问题