Python 正则 re.sub替换

# 正则将匹配到的两个字段,都替换成某个值
import
re s0 = 'BOY and GIRL' s1 = re.sub(r'BOY|GIRL', 'HUMAN', s0) print s1 # HUMAN and HUMAN

 

posted @ 2017-12-19 14:15  yooma  阅读(3332)  评论(0编辑  收藏  举报