Is there a way to "insert" a Unicode character into a string in Python 3? For example,
>>>import unicode
>>>string = 'This is a full block: %s' % (unicode.charcode(U+2588))
>>>print(string)
This is a full block: █
Is there a way to "insert" a Unicode character into a string in Python 3? For example,
>>>import unicode
>>>string = 'This is a full block: %s' % (unicode.charcode(U+2588))
>>>print(string)
This is a full block: █
Yes, with unicode character escapes:
print u'This is a full block: \u2588'
You can use \udddd
where you replace dddd
with the the charcode.
print u"Foo\u0020bar"
Prints
Foo bar
You can use \u to escape a Unicode character code:
s = u'\u0020'
which defines a string containing the space character.