In python3.6, I tried

In [60]: a = '\a'
In [61]: b = '\b'
In [62]: c = '\c'
In [63]: l =[a, b, c]

If test l

In [64]: l
#it output following list instead of  ['a','\b','\c']
Out[64]: ['\x07', '\x08', '\\c']

encapsulate them directly in a list.

In [70]: ['\a','\b','\c']
#it output following list instead of  ['a','\b','\c']
Out[70]: ['\x07', '\x08', '\\c']

What's the mechanism behind it?


closed as off-topic by quicksort, Raphael Jan 11 '18 at 11:49

  • This question does not appear to be about computer science within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.


Backslash is the escape character to allow you to enter non-printable characters into a string literal.

One of the most known escape sequences for example is \n for a newline.

\a is the bell character and \b is the backspace character.


Not the answer you're looking for? Browse other questions tagged or ask your own question.