I'm trying to replace backslashes or front slashes in a string with double backslashes. I've tried a couple of things but it doesn't seem to work.¨
My work so far:
string = 'C:\Users\Victor\Dropbox\Private\files\test.txt'
f = re.sub(r'[\\\/]', '\\\\', string)
This prints the string:
'C:\Users\Victor\Dropbox\Privateiles est.txt'
But what i really want is a string that looks like this:
'C:\\Users\\Victor\\Dropbox\\Private\\files\\test.txt'
So that when i print the string it will look like the original
'C:\Users\Victor\Dropbox\Private\files\test.txt'