print python emoji as unicode string

前端 未结 6 1922
谎友^
谎友^ 2020-12-03 13:48

I\'ve been trying to output \"\" as \'\\U0001f604\' instead of the smiley but it doesn\'t seem to work.

i tried

6条回答
  •  暖寄归人
    2020-12-03 14:41

    If this is for debugging purposes, you could use %r as the format specifier.

    >>> print '%r' % u'\U0001f604'
    u'\U0001f604'
    

提交回复
热议问题