What is the use of '\b' (backspace)

前端 未结 4 1718
我寻月下人不归
我寻月下人不归 2021-01-13 16:30

I\'m taking a Python class right now, and I just learned about the backspace character. Like newline (\\n), backspace is a special character with ASCII code 8. My teacher c

4条回答
  •  不知归路
    2021-01-13 17:01

    This is not a feature of Python, but a symbol defined by ASCII. Python just supports it (like all other languages).

    More specifically, it is a control character that is used either to erase the last character printed or to overprint it. The first version of ASCII was published in 1963 when the common way to output symbols was to send them to a printer and physically print the letters on paper. Here's an excerpt from Wikipedia:

    Printing control characters were first used to control the physical mechanism of printers, the earliest output device. [...] The backspace character (BS) moves the printing position one character space backwards. On printers, this is most often used so the printer can overprint characters to make other, not normally available, characters. On terminals and other electronic output devices, there are often software (or hardware) configuration choices which will allow a destruct backspace (i.e., a BS, SP, BS sequence) which erases, or a non-destructive one which does not.

提交回复
热议问题