Python 中文字符串正则表达式

import re

s='='金''

#只保留金这个字

s=re.sub(r'\W','',s)

#去掉金字

s=re.sub(r'\w','',s)

posted @ 2018-08-01 16:25  The_Chain  阅读(446)  评论(0编辑  收藏  举报