This is one way to do it (in Python 3.x): escaped = a_string.translate(str.maketrans({"-": r"\-", "]": r"\]", "\\": r"\\", "^": r"\^", "$": r"\$", ...
確定! 回上一頁