I have been having a horrible time just trying to open a file in python 3 because of the "\U" in the "C:\Users..." microsoft path name. I'm getting the error "SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes..."
I've read the other answers to this problem that offer the following solutions:
Double the \ to escape the unicode of the "\U"
Use a raw string filename = r"C:\Users.."
Switch the \ to /.
Whenever I use option 1 and/or 2 it doubles the "\". So, the filepath is wrong because it reads 'C:\\Users\\..." instead of 'C:\Users\...'
I'm trying to open excel files at work to manipulate data, and so option 3 isn't available to me, as I can't change the filepath.
Can someone explain why the "\" are doubling when I use the escape "\" or a raw string?
I've tried every combination of options and can't seem to get this to work.
Sorry for making a new question to an already answered problem, but I couldn't comment on the other answers, and the accepted answers weren't working for me.
Thanks
pwd>>> os.system("pwd") /Users/omer/Dropbox/school/16_fallreprof the string at the interactive console, which shows the escapes you'd need to recreate the string if you were typing it out. Try doingprint(escaped_string), you won't see the escapes becauseprintis showing you the human friendly version of the string, w/o the escapes.