path_better = path.replace('/','\\')
To convert the forward slashes to backward ones. Note that the reason why I used TWO backslashes is because the single backslash escapes special characters (except in raw strings).
Of course, if what you need is to convert from backward to forward slash, just swap the order in the brackets. That is --> ('\\','/')
Tags: Converting Convert backward forward slash slashes