导航

python re.sub第二参数,前值如何引用

Posted on 2026-03-28 18:08  pcwanli  阅读(3)  评论(0)    收藏  举报

re.sub(r'(\d+)_abc',r'\1',content,flags=re.M)

或者

re.sub(r'(\d+)_abc','\\1',content,flags=re.M)

或者

re.sub(r'(\d+)_abc',r'\g<1>',content,flags=re.M)