我使用python 2.7.9将unicode hex转换为unicode文本,但我仍然坚持使用以下代码:
text = '0421'
converted_text = ''.join([chr(int(''.join(c), 16)) for c in zip(text[0::4], text[1::4], text[2::4], text[3::4])])
print converted_text
ValueError: chr() arg not in range(256)
当我删除chr()时:
converted_text = ''.join([int(''.join(c), 16) for c in zip(text[0::4], text[1::4], text[2::4], text[3::4])])
TypeError: sequence item 0: expected string, int found
如果我尝试其他文字,例如&00; 00DD'它工作正常。 知道我的代码中有什么问题吗?