天天看點

Python 中文字元串正規表達式

import re

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

#隻保留金這個字

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

#去掉金字

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

Python 中文字元串正規表達式