Reputation: 321
I'm quite new to python and i've been trying to get this working with no success.
Is there any way to make something like this work
unicode_code = "00000061"
character = "\u" + unicode_code
A example would be appreciated.
Upvotes: 0
Views: 144
Reputation: 30153
Literals are notations for constant values of some built-in types.
Unless an '
r
' or 'R
' prefix is present, escape sequences in strings are interpreted according to rules similar to those used by Standard C:
…
\uxxxx
Character with 16-bit hex valuexxxx
(Unicode only)\Uxxxxxxxx
Character with 32-bit hex valuexxxxxxxx
(Unicode only)…
Unfortunately, neither "\u" + "0061"
nor "\U" + "00000061"
satisfy condition of constant values as they both are expressions.
Upvotes: 1