How to convert some character into five digit unicode one in Python 3.3?

后端 未结 2 1368
别跟我提以往
别跟我提以往 2020-12-20 21:00

I\'d like to convert some character into five digit unicode on in Python 3.3. For example,

import re
print(re.sub(\'a\', u\'\\u1D15D\', \'abc\' ))

2条回答
  •  南方客
    南方客 (楼主)
    2020-12-20 21:39

    By the way, you do not need the re module for this. You could use str.translate:

    >>> 'abc'.translate({ord('a'):'\U0001D15D'})
    '

提交回复
热议问题