def fix(line):
    """
    returns the corrected line, with all apostrophes prefixed by an escape character
    >>> fix("DOUG\\'S")
    "DOUG\\\\'S"
    >>> fix("DOUG'S") == r"DOUG\\'S"
    True
    >>> fix("DOUG'S")
    "DOUG\\\\'S"
    """
return line.replace("'", "\\'")
Doctest с участием экранирующих персонажей