Skip to content Skip to sidebar Skip to footer

Python Automatically Ignore Unicode String

I've been searching to automatically import some files but since I'm on Windows i got the unicode error (because of the 'C:\Users\...'). I've been looking to correct this error an

Solution 1:

That's a very frequent issue with windows paths. I suspect that people stumble upon it, and figure out a way by putting the "annoying" lowercase letters matching escape sequences (\n,\t,\b,\a,\v,\x ...) in upper case. It works, except for \U (which is unicode escape sequence) and \N .

The real solution is to use raw prefix to treat backslashes literally:

MyFilePath = r"C:\Users\MyUser\Desktop\Projet\05_Statistiques\Data\MyFileName.xlsx"
             ^

EDIT: my theory about "bug avoidance by uppercase confirms. Check the path in this question: Largest number of rows in a csv python can handle?

Post a Comment for "Python Automatically Ignore Unicode String"