Two problems with backslashes
Skip Montanaro
skip at pobox.com
Wed Jul 4 10:21:07 EDT 2001
>>> path = 'e:\test\test.txt'
>>> path.replace('\\', '/')
'e:\test\test.txt'
Your first statement should be either
path = 'e:\\test\\test.txt'
or
path = r'e:\test\test.txt'
Gustaf> Also, split() doesn't like backslashes:
>>> paths = 'e:\test\file1.txt e:\test\file2.txt'
>>> paths.split()
['e:', 'est', 'ile1.txt', 'e:', 'est', 'ile2.txt']
Again, you're not escaping your backslashes. The '\t' sequence means ASCII
TAB. If you double up your backslashes or use raw strings I think you'll
find everything works as expected.
--
Skip Montanaro (skip at pobox.com)
(847)971-7098
More information about the Python-list
mailing list