python 判断控制符 unicode str

来源:互联网 发布:适合初学者的php集成 编辑:程序博客网 时间:2024/06/06 04:15

import codecsf = codecs.open('unicode.rst', encoding='utf-8')



def rm_control_characters(string):    return "".join(ch if not unicodedata.category(ch)=='Cc' else ',' ch in unicode(string))

>>> print u'Hello, 你好, bye.'.encode('unicode-escape')Hello, \u4f60\u597d, bye.

0 0
原创粉丝点击