天天看点

Python 中文字符串正则表达式

import re

s=\'=\'金\'\'

#只保留金这个字

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

#去掉金字

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

Python 中文字符串正则表达式