If you enter the following in python interactive mode, I heard that the \ before the'is displayed.
>>> "\"No, I can\'t\" He said."
# '"No, I can\'t" He said.'Is displayed
>>> print("\"No, I can\'t\" He said.")
# "No, I can't" He said.No escape symbol
If you use it as an argument of print (), it will appear as intended.
This behavior is by design. A similar case is introduced in the official Doc. It's embarrassing ... I will consider why it is the specification in the future based on the comments I received.
~~ Let's write a prediction about it. (I may find the basis soon ~~
https://www.python.org/shell/
"abc" →'abc' """" →'""' ""'" →'"'' "''" → "''" "a'" → "a'"
---'Will be preceded by \ when "and' are mixed --The character string is output by enclosing it in', but if it contains', enclose it in "(this is a specification).
The following is a consideration of slipping, so I erased it. Really embarrassing ...
~~ Isn't it like this?
As I got in the comment, I would like to investigate the difference between str () and repr () and think about why it settled down to the current output. However, if you know Python, it may be an immediate answer level, so I may delete the article.
[^ 1]: In Bash, it seems that \ is not escaped when you enclose a string with ""
[^ 2]: By the way, if you enter'\ "'+" '", it will be output as'"''. If it is "'" alone, "'" will be displayed, so it may be suspicious that the combination is strange.