使用正则表达是查找汉字之前,要将所有的字符串都转码成utf8

import re


string_test = "This is test string 这是测试字符串"
string_test = string_test.decode('utf-8')  # 转码

pattern = ur'[\u4e00-\u9fff]+'  # 汉字正则表达式
re_compile = re.compile(pattern)

res = re_compile.findall(string_test)
print res

 

posted on 2018-03-19 17:00  Go_Forward  阅读(1163)  评论(0编辑  收藏  举报