
使用功能进行替换
s = 'The struct-of-application and struct-of-world'p = re.compile('((w+-)+w+)')def replace(match): return 'http://{}'.format(match.group()) #for python 3.6+ ... #return f'http://{match.group()}'>>> p.sub(replace, s)'The http://struct-of-application and http://struct-of-world'>>>欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)