Reputation: 21
I have an entry field that allows the user to enter their own directory/path structure when saving a file, if the user just copies their directory from windows explorer you can get text like "c:\directory\file.ext" how can I take text entered like that and replace it with the necessary "\" for the os module to use?
Upvotes: 1
Views: 168
Reputation: 31
Use a raw string to get the backslashes
>>> path = r"c:\test\123"
>>> path
'c:\\test\\123'
>>> print path
c:\test\123
Upvotes: 1