转义字符

基本类型 / 字符类型

# \' for a single quote.
c = '\''
print(f"{c = }")

# \" for a double quote.
c = '\"'
print(f"{c = }")

# \\ for a backslash.
c = '\\'
print(f"{c = }")

# \0 for a null character.
c = '\0'
print(f"{c = }")

# \a for an alert character.
c = '\a'
print(f"{c = }")

# \b for a backspace.
c = '\b'
print(f"{c = }")

# \f for a form feed.
c = '\f'
print(f"{c = }")

# \n for a new line.
c = '\n'
print(f"{c = }")

# \r for a carriage return.
c = '\r'
print(f"{c = }")

# \t for a horizontal tab.
c = '\t'
print(f"{c = }")

# \v for a vertical tab.
c = '\v'
print(f"{c = }")

# \x for a unicode character hex value.
c = '\x41'  # Symbol A
print(f"{c = }")

# \u for a four-digit hex value.
c = '\u00a9'  # Copyright Symbol
print(f"{c = }")

# \ and up to three octal digits for an octal code.
c = '\101'  # Symbol A
print(f"{c = }")

# No \e for the escape character: use its hex code.
c = '\x1b'
print(f"{c = }")