python转义序列
Escape sequences allow you to include special characters in strings. To do this, simply add a backslash (\
) before the character you want to escape.
转义序列允许您在字符串中包括特殊字符。 为此,只需在要转义的字符之前添加反斜杠( \
)。
For example, imagine you initialized a string with single quotes:
例如,假设您使用单引号初始化了一个字符串:
s = 'Hey, whats up?'
print(s)
Output:
输出:
Hey, whats up?
But if you include an apostrophe without escaping it, then you will get an error:
但是,如果您在没有转义的情况下加入了撇号,则会出现错误:
s = 'Hey, what's up?'
print(s)
Output:
输出:
<