正则findall的使用

import re

title = 'hello, 你好,world'
print(title)

title = u'hello, 你好,world'
print(title)

#汉字匹配 +的意思是找到一个汉字 继续找直到找完 然后统一打印出来
#如果没有+号  则一个汉字一个汉字打印出来
pattern = re.compile(u'[\u4e00-\u9fa5]+')
s = pattern.findall(title)
print(s)

 

posted @ 2018-03-10 21:44  Bob__Zhang  阅读(113)  评论(0编辑  收藏  举报