I can't open a file if its path contains a folder which name starts with double underscore. For example:
File = open('C:\user\__foldername\file.txt')
It works if the folder's name starts with only one underscore , but unfortunately I can't rename it.
Is there any solution for this?
The reason the file is not opening is not because of the double underscore, it is because there is an escape character somewhere in the string. Windows paths should be defined using a raw string literal - by putting an
rbefore the opening quote, escaping the back slashes, or by using forward slashes:Just having a double underscore somewhere in the path shouldn't affect anything, it's still a valid path name.