See the string literal documentation:

\b ASCII Backspace (BS)

It produces a backspace character. Your terminal backspaced over the second o when printing that character.

Answer from Martijn Pieters on Stack Overflow
Discussions

Slash vs backslash to separate folders
but whenever I copy a file address in Windows it copies with the folders separated by backslashes You should use an appropriate type for file paths, such as pathlib or os.path (low level), which handles the directory separators for you. https://docs.python.org/3/library/pathlib.html More on reddit.com
๐ŸŒ r/learnpython
7
3
February 1, 2024
how to solve Ax=b without backslash operator and inv() function?
How would you go about solving this by hand? Once you have that, it is just a matter of implementing it in matlab. More on reddit.com
๐ŸŒ r/matlab
8
3
September 9, 2022
What is \b realistically used for?
The other time you might want to use it is if say you had a string which said "loading..." and then had say a percentage or a "text spinner" at the end (i.e. loops through | / - \ |). You can print the \b character however many times required to only update that bit of text on the screen, eliminating (or at least vastly reducing) flickering/refreshing/repetition of text. from time import sleep s="|/-\\" print("Loading....", end="", flush=True) for i in range(20): print(f"\b{s[i%len(s)]}", end="", flush=True) sleep(0.5) (Edit) included flush=True as per suggestions. More on reddit.com
๐ŸŒ r/Python
49
273
December 24, 2021
[Python] cรณmo encontrar una barra diagonal inversa simple ...
That's because just typing x doesn't show you the string. It shows you repr(x), which shows you the escape sequences so you can more readily tell what's in the string. >>> x = '\thello' >>> x '\thello' >>> print(x) hello ยท If you print x (the way you'd need to do in a real program- just leaving the bare variable only does something in the interactive console), it'll only show a single backslash... More on reddit.com
๐ŸŒ r/learnprogramming
February 16, 2020
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ gloss_python_escape_characters.asp
Python Escape Characters
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Practice Problems Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Training ... To insert characters that are illegal in a string, use an escape character. An escape character is a backslash \ followed by the character you want to insert.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-escape-characters
Python Escape Characters - GeeksforGeeks
April 28, 2025 - The \b escape character moves the cursor one character back, effectively deleting the last character. ... The \f escape character moves the cursor to the next page (less commonly used in modern programming).
๐ŸŒ
Python Morsels
pythonmorsels.com โ€บ raw-strings
Raw strings - Python Morsels
August 12, 2021 - Because those \b represent an escape sequence, they don't end up giving us any matches. Whenever I'm making a regular expression in Python, I always prefix it with an r (just in case). Raw strings are a way of making a string in Python that has no escape sequences and instead reads every backslash as a literal backslash.
๐ŸŒ
Imperial College London
python.pages.doc.ic.ac.uk โ€บ 2022 โ€บ lessons โ€บ regex โ€บ 04-boundary โ€บ 03-boundary.html
Advanced Lesson 1: Regular Expressions > Word boundary | Python Programming (70053 Autumn Term 2022/2023) | Department of Computing | Imperial College London
Note: you need to be careful when implementing this in Python. \b is actually the backspace character. So you will have to escape the backslash by using \\b instead, i.e. "\\bred\\b". Alternatively and preferably, use a Python raw string literal: r"\b" is equivalent to "\\b".
๐ŸŒ
Python documentation
docs.python.org โ€บ 3 โ€บ reference โ€บ lexical_analysis.html
2. Lexical analysis โ€” Python 3.14.5 documentation
A backslash is illegal elsewhere on a line outside a string literal. Expressions in parentheses, square brackets or curly braces can be split over more than one physical line without using backslashes.
Find elsewhere
๐ŸŒ
Quora
quora.com โ€บ How-do-you-backslash-a-string-in-Python
How to backslash a string in Python - Quora
Scale everything in one click. Explore VPS plans. ... To include literal backslashes in Python strings you must escape each backslash (write \) or use raw string literals when appropriate.
๐ŸŒ
LearnByExample
learnbyexample.github.io โ€บ py_regular_expressions โ€บ escaping-metacharacters.html
Escaping metacharacters - Understanding Python re(gex)?
However, \b is for word boundaries as seen earlier, whereas it stands for the backspace character in normal string literals. The full list is mentioned at the end of the docs.python: Regular Expression Syntax section as \a \b \f \n \N \r \t ...
๐ŸŒ
GitConnected
levelup.gitconnected.com โ€บ escaping-backslash-hell-in-python-0550bc7a2db3
Escaping Backslash Hell in Python | by Liu Zuo Lin | Level Up Coding
October 24, 2024 - The \ (backslash) character is used to escape other characters โ€” \n (newline), \t (tab) and so on. So if we want to print \, we need to use another \ to escape it: ... If we want to print \\\, we need one \ each to escape each \ โ€” meaning ...
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ escape-sequences-python
Escape Sequences in Python
January 3, 2020 - 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) Outp...
๐ŸŒ
InterServer
interserver.net โ€บ home โ€บ python โ€บ how to use escape characters in python strings effectively
How to Use Escape Characters in Python Strings Effectively - Interserver Tips
January 8, 2026 - This may cause an error because \U starts a Unicode escape sequence. To avoid this, use double backslashes: ... This tells Python to treat each backslash literally.
๐ŸŒ
MojoAuth
mojoauth.com โ€บ special-characters โ€บ backspace-b-in-python
Backspace (\b) in Python | Understanding Special Characters in Programming
The backspace character, represented as \b, is an important control character in Python that allows for the manipulation of text output in a terminal or console. When \b is utilized in a string, it moves the cursor one position back, effectively ...
๐ŸŒ
Python Examples
pythonexamples.org โ€บ python-escape-characters
Python Escape Characters
To specify a byte using hex value, use a preceding backslash and x for two digit hex value in the string. ... Hex value of 41 means 65 in decimal. And a byte with decimal 65 represents the character A. Similarly 42 is B, 43 is C. In this tutorial of Python Examples, we learned what escape characters are, how to use them in a string, and their usage, with the help of example programs for each of the escape characters.
๐ŸŒ
Python Forum
python-forum.io โ€บ thread-37781.html
change backslash into slash in a path
July 21, 2022 - Hi Typically in a Windows path, I want to change the special 'backslash' character to 'slash' one. I was thinking re.sub substitutes all occurences but whatever I've tested so far, it fails (same result using replace()): what I'm missing? Path = 'D...
๐ŸŒ
Python documentation
docs.python.org โ€บ 3 โ€บ library โ€บ re.html
re โ€” Regular expression operations โ€” Python 3.14.6 ...
2 weeks ago - However, Unicode strings and 8-bit ... use the backslash character ('\') to indicate special forms or to allow special characters to be used without invoking their special meaning....
๐ŸŒ
Python documentation
docs.python.org โ€บ 3 โ€บ howto โ€บ regex.html
Regular expression HOWTO โ€” Python 3.14.5 documentation
Letโ€™s say you want to write a RE that matches the string \section, which might be found in a LaTeX file. To figure out what to write in the program code, start with the desired string to be matched. Next, you must escape any backslashes and other metacharacters by preceding them with a backslash, resulting in the string \\section.
๐ŸŒ
Shefali
learnify.shefali.dev โ€บ tutorials โ€บ python-escape-sequence-character
Python Escape Sequence Characters | Learnify
print("This is a backslash: \\") #output: This is a backslash: \ \' - Single Quote: This allows you to insert a single quote inside a string that is enclosed by single quotes.
๐ŸŒ
TOOLSQA
toolsqa.com โ€บ python โ€บ escape-sequences-in-python
Escape Sequences in Python (with examples) - ToolsQA
That is to say; backlash signifies that the next character after it has a different meaning. It could be printing double quotes or indicating a new line. Let's see what escape sequences are and how to use them in Escape Sequences in Python. The sequence of characters after a backslash is known as an escape sequence.
๐ŸŒ
Scaler
scaler.com โ€บ home โ€บ topics โ€บ escape sequence in python
Escape Sequence in Python - Scaler Topics
April 23, 2024 - It happened because of the backslash (โ€˜\โ€™) before any character tells the interpreter that this combination is an escape sequence in python, removing the backslash from the string and putting the quote inside the string.