📅  最后修改于: 2022-03-11 14:46:30.480000             🧑  作者: Mango
using re adds white-space before and after the desired characters:
import re
pat = re.compile(r"([.()!])")
print (pat.sub(" \\1 ", string))
# hello . . . ( world ) !