unicode - Python escape sequence \N{name} not working as per definition -


i trying print unicode characters given name follows:

# -*- coding: utf-8 -*- print "\n{solidus}" print "\n{black spade suit}" 

however output not encouraging.

the escape sequence printed is.

activepython 2.7.2.5 (activestate software inc.) based on python 2.7.2 (default, jun 24 2011, 12:21:10) [msc v.1500 32 bit (intel)] on type "help", "copyright", "credits" or "license" more information. >>> # -*- coding: utf-8 -*- ... print "\n{solidus}" \n{solidus} >>> print "\n{black spade suit}" \n{black spade suit} >>> 

i can see another asker has been able successfully.

what's wrong?

those sequences work in unicode strings, kind of string python 3 has. in python 2 need prefix string literal u.

>>> print "\n{solidus} \n{black spade suit}" \n{solidus} \n{black spade suit} >>> print u"\n{solidus} \n{black spade suit}" / ♠ 

relevant line docs:

\n{name} character named name in unicode database (unicode only)


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -