import re # title = 'hello , 你好,world!' # print(title) title = u'hello , 你好,world!' print(title) # pattern=re.compile(u'[\u4e00-\u9fa5]+')#unicode # s=pattern.findall(title) # print(s)#['你好'] pattern=re.compile(u'[\u4e00-\u9fa5]')#unicode s=pattern.findall(title) print(s)#['你', '好']
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 /Users/apple/PycharmProjects/stage4/spider/2018——0307/re_zh.py
hello , 你好,world!
['你', '好']
Process finished with exit code 0