Two problems with backslashes

Emile van Sebille emile at fenx.com
Wed Jul 4 10:47:40 EDT 2001


You don't have back-slashes in your path and paths strings.  You've got
tabs.  Try using
path = r'e:\test\test.txt'
paths = r'e:\test\file1.txt e:\test\file2.txt'

HTH,

--

Emile van Sebille
emile at fenx.com

---------
"Gustaf Liljegren" <gustafl at algonet.se> wrote in message
news:Xns90D4A141E71CDgustaflalgonetse at 194.213.69.148...
> I have two problems with backslashes in DOS path strings:
>
> >>> path = 'e:\test\test.txt'
> >>> path.replace('\\', '/')
> 'e:\test\test.txt'
>
> Expected:
>
> 'e:/test/test.txt'
>
> 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']
>
> Expected:
>
> ['e:\test\file1.txt', 'e:\test\file2.txt']
>
> Alternative ways would be much appreciated.
>
> Regards,
>
> Gustaf Liljegren




More information about the Python-list mailing list