Having some trouble including a single pair of backslashes in the result of a formatted string in Python 3.6. Notice that #1 and #2 produce the same unwanted result, but #3 results in too many backslashes, another unwanted result.
1
t = "arst '{}' arst" t.format(d) >> "arst '2017-34-12' arst" 2
t = "arst \'{}\' arst" t.format(d) >> "arst '2017-34-12' arst" 3
t = "arst \\'{}\\' arst" t.format(d) >> "arst \\'2017-34-12\\' arst" I'm looking for a final result that looks like this:
>> "arst \'2017-34-12\' arst"
repr()of the result, which shows what you'd need to type back into Python to get that string, including escapes. The actual string contains only a single backslash, as you can see viaprint(t.format(d))."arst '{}' arst,\"you said\"".format(d). Since this has a mixture of both'` and"then escape is necessary. If all the inside are'while the outside are"then there will be no need of escaping. Also if you all of them are the same, then it will converse one to the other so as it might be readable