python替换部分参数, 进行局部替换 使用\1,\2 import re s = 'i o u! u 2?' s = re.sub('([.!?])', ' \\1', s) # re.sub(r'([.!?])', r' \1', s) print(s) 使用lambda表达式