Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 变量中的Unicode字符名_Python 3.x_Python Unicode - Fatal编程技术网

Python 3.x 变量中的Unicode字符名

Python 3.x 变量中的Unicode字符名,python-3.x,python-unicode,Python 3.x,Python Unicode,我想使用字符名创建一个unicode字符串,如下所示(已找到): 但是在变量中有字符的名称。像 myChar = "GREEK CAPITAL LETTER DELTA" myString = "\N{myChar}" # causes SyntaxError: (unicode error) 我尝试了很多基于format()的方法,但都没有成功。 有人知道怎么做吗?使用 myChar = "GREEK CAPITAL LETTER DELTA" myString = "\N{myChar

我想使用字符名创建一个unicode字符串,如下所示(已找到):

但是在变量中有字符的名称。像

myChar = "GREEK CAPITAL LETTER DELTA"
myString = "\N{myChar}"   # causes SyntaxError: (unicode error)
我尝试了很多基于format()的方法,但都没有成功。
有人知道怎么做吗?

使用

myChar = "GREEK CAPITAL LETTER DELTA"
myString = "\N{myChar}"   # causes SyntaxError: (unicode error)
>>> import unicodedata
>>> my_char = "GREEK CAPITAL LETTER DELTA"
>>> unicodedata.lookup(my_char)
'Δ'