1---- backspace
simply move the cursor to the left one space, and
if you use the work or other editor it will also delete the left one character.
and what you must know is that backspace
is also a character the same as 1
or a
.
2---- the terminal as our default output device, you can also put him as a file.
So if you use
print '1\x08'
it means that you write a 1
and a backspace
in the file stdout.
if you read the file, the system reads 1 + breakspace
, you will get an 1
.
and if you use
print '1\x082'
it means that you write a 1
, a backspace
and a 2
in the file stdout.
if you read the file, the system get 1 + breakspace + 2
, when you print them, you will only get an 2
, because it covers the first 1
when you use backspace.
for detail you can see the next test code
if __name__ == "__main__":
print "1\x08"
print "1\x082"
f = open("1.txt", "w")
f.write("1\x08\x082")
f.close();
f = open("1.txt", "r")
str = f.readlines( )
print len(str), str
for s in str:
print "s=|" + s + "|"

you can see the string s=|1\x08\x082|
display s=2|
. becasue the |1
not display when backspace
two times.