Apr-28-2023, 07:17 PM
You are not allowed to end a string literal with an odd number of backslashes. It doesn't matter if the string is raw or not. So if you need a single backslash at the end of a string, you cannot use a raw string.
FPath = "C:\\Users\\mishal.mohanlal\\Desktop\\" # this worksAmong the other options mentioned (I like pathlib the best), you can also use forward slashes. This will work as a file path in windows even though windows uses backslashes in file paths. Python fixes the separator when opening a file. It addition to avoiding the escape sequence nightmare, this lets you write code that runs on windows an linux.
FPath = "C:/Users/mishal.mohanlal/Desktop/"