Hi I have read articles related converting backward to forward slashes. But sol was to use raw string.
But Problem in my case is :
I will get file path dynamically to a variable var='C:\dummy_folder\a.txt' In this case i need to convert it to Forward slashes. But due to '\a',i am not able to convert to forward slashes
How to i convert it? OR How should i change this string to raw string so that i can change it to forward slash
Don't do this. Just use os.path and let it handle everything. You should not explicitly set the forward or backward slashes.
>>> var=r'C:\dummy_folder\a.txt' >>> var.replace('\\', '/') 'C:/dummy_folder/a.txt'
But again, don't. Just use os.path and be happy!