python 正则笔记

# 将变量b中"连续的空格"替换为"一个空格"
re.sub("\s+", " ", b)

# 整词替换
# old/new里若带括号则失败
re.sub(r"\b%s\b" % (old), new, src)
请使用浏览器的分享功能分享到微信等