Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
mystring = 'hello\\xxyy'

print(mystring)
# oops! \ is interpreted as an escape in this case

mystring = 'hello\\\\xxyy'
print(mystring)
# this works, but is ugly

mystring = r'hello\\xxyy'
print(mystring)
# using raw strings lets us tell the interpreter that we mean exactly what we typed

print('\\' in mystring) # tests if there is ONE \ in the string
print(r'\\' in mystring) # tests if there are TWO \ in the string
print('\\\\\\' in mystring) # tests if there are THREE \ in the string
Python 3.6.1 (default, Dec 2015, 13:05:11) [GCC 4.8.2] on linux