Created
July 27, 2015 10:01
-
-
Save ficapy/cc4a974228751942a16d to your computer and use it in GitHub Desktop.
获取文本的unicode编码拼凑字符串
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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