In [1]:
s = 'a\tb\nA\tB'
print(s)
In [2]:
rs = r'a\tb\nA\tB'
print(rs)
In [3]:
print(type(rs))
In [4]:
print(rs == 'a\\tb\\nA\\tB')
In [5]:
print(len(s))
In [6]:
print(list(s))
In [7]:
print(len(rs))
In [8]:
print(list(rs))
In [9]:
path = 'C:\\Windows\\system32\\cmd.exe'
rpath = r'C:\Windows\system32\cmd.exe'
print(path == rpath)
In [10]:
path2 = 'C:\\Windows\\system32\\'
# rpath2 = r'C:\Windows\system32\'
# SyntaxError: EOL while scanning string literal
rpath2 = r'C:\Windows\system32' + '\\'
print(path2 == rpath2)
In [11]:
s_r = repr(s)
print(s_r)
In [12]:
print(list(s_r))
In [13]:
s_r2 = repr(s)[1:-1]
print(s_r2)
In [14]:
print(s_r2 == rs)
In [15]:
print(r'\t' == repr('\t')[1:-1])
In [16]:
# print(r'\')
# SyntaxError: EOL while scanning string literal
In [17]:
print(r'\\')
In [18]:
# print(r'\\\')
# SyntaxError: EOL while scanning string literal