Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
获取文本的unicode编码拼凑字符串
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: Ficapy
# Create: '15/7/27'
# from __future__ import unicode_literals
# 兼容2和3
x = '啦啦啦,'
try:
x = unicode(x, 'utf-8') if isinstance(x, str) else x
except:
pass
print(''.join((i.encode('unicode_escape')).decode('utf-8') for i in x).replace('\\u', '%u'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.