Converting numbers to unicode charaters
Duncan Booth
duncan.booth at invalid.invalid
Mon Sep 24 10:43:36 EDT 2007
Laurent Pointal <laurent.pointal at limsi.fr> wrote:
> You may eventually use a more condensed expression and avoid n
> concatenation of n chars using join, like this:
>
> >>> u''.join(unichr(int(x,16)) for x in ['42','72','61','64'])
> u'Brad'
Or even avoid the loop completely:
>>> hexs = ['42', '72', '61', '64']
>>> u'\\x'.join(['']+hexs).decode('string-escape')
'Brad'
(but for that to work you really do need to be sure that all the values are
2 characters).
More information about the Python-list
mailing list