#coding=utf-8
import re
s = 'hi新手oh'.decode('utf-8') #举个栗子是字符串s,为了匹配下文的unicode形式,所以需要解码
p = re.compile(ur'[\u4e00-\u9fa5]') #这里是精髓,[\u4e00-\u9fa5]是匹配所有中文的正则,因为是unicode形式,所以也要转为ur
print p.split(s) #使用re库的split切割
python拆分中英文混合字符串
最新推荐文章于 2025-03-31 18:26:32 发布