如何在Python中连接和输出unicode文本变量

Mar*_*raM 1 python unicode

我的标题术语可能不正确,可能是我无法从网站上找到这个简单的东西的原因.

我有一个字符串变量列表.我如何实际连接它们并在Python中输出一个真正的unicode语句?

base = ['280', '281', '282', '283']
end = ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f']
unicodes = [u''.join(['\u', j, i]) for j in base for i in end]

for u in unicodes:
    print u
Run Code Online (Sandbox Code Playgroud)

我只会得到像'\ u280F'这样的字符串而不是真正的字符.但如果我这样做:

print u'\u280F'
Run Code Online (Sandbox Code Playgroud)

出现正确的符号,即:⠏

而且我确信有更优雅的方式来获得从u2800到u283F的一系列符号......

fal*_*tru 5

CONVER字符串到整数(使用intbase16),使用unichr(chr如果你使用Python 3.X)将数字转换成Unicode对象.

>>> int('280' + 'F', 16)  # => 0x280F, 16: hexadecimal
10255
>>> unichr(int('280' + 'F', 16))  # to unicode object
u'\u280f'
>>> print unichr(int('280' + 'F', 16))
?
Run Code Online (Sandbox Code Playgroud)
base = ['280', '281', '282', '283']
end = ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f']
unicodes = [unichr(int(j + i, 16)) for j in base for i in end]

for u in unicodes:
    print u
Run Code Online (Sandbox Code Playgroud)