python正则表达式应用

import re
ab='''ms: [["", "\u7acb\u5373\u4e0b\u8f7d"], ["", "\u5207\u6362\u81f3\u4e2a\u4eba\u8d26\u53f7\u4e0b\u8f7d"],'''
ab=re.sub(r' +','',ab) #将ab中的所有空格替换
abb=re.findall(r'([\u4e00-\u9fa5]+)',ab) #获取字符串中的所有中文
print(abb)

结果:

===================== RESTART: D:/Python/Python37/re6.py =====================
['立即下载', '切换至个人账号下载']
>>>

猜你喜欢

转载自www.cnblogs.com/xkdn/p/12322011.html
今日推荐