There are (at least) two different ways to achieve what you want, either using a raw string (as described by the other answers):
pass__ = r'HSSSTS00008\4Tech'
or it would be possible to write it using the escape sequence '\\'
in a normal string:
pass__ = 'HSSSTS00008\\4Tech'
Both of these will generate the same string. When looking at the string representation, i.e., what you get if you just write the variable name in the interpreter or print the .__repr__()
representation you will see:
>>> pass__
'HSSSTS00008\\4Tech'
>>> print(pass__.__repr__())
'HSSSTS00008\\4Tech'
Thus, the program representation of the string is with double backslashes \\
. But when printing the string you will get a single slash:
>>> print(pass__)
HSSSTS00008\4Tech
The reason for this, is that a single backslash is used as an escape character to allow representation of e.g. non-printable characters as ´'\n'` (new line).
It is also possible to use the escape sequence to generate any unicode character, which is just a single backslash followed by the number describing the code point. Thus '\4'
will be interpreted as code point 4. When showing the representation it is done in hex, which means that it will be represented as '\x04'
.