"Unicode Error "unicodeescape" codec can't decode bytes... Cannot open text files in Python 3 -


i using python 3.1, on windows 7 machines. russian default system language, , utf-8 default encoding.

looking @ answer previous question, have attempting using "codecs" module give me little luck. here's few examples:

>>> g = codecs.open("c:\users\eric\desktop\beeline.txt", "r", encoding="utf-8") syntaxerror: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-4: truncated \uxxxxxxxx escape (<pyshell#39>, line 1) >>> g = codecs.open("c:\users\eric\desktop\site.txt", "r", encoding="utf-8") syntaxerror: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-4: truncated \uxxxxxxxx escape (<pyshell#40>, line 1) >>> g = codecs.open("c:\python31\notes.txt", "r", encoding="utf-8") syntaxerror: (unicode error) 'unicodeescape' codec can't decode bytes in position 11-12: malformed \n character escape (<pyshell#41>, line 1) >>> g = codecs.open("c:\users\eric\desktop\site.txt", "r", encoding="utf-8") syntaxerror: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-4: truncated \uxxxxxxxx escape (<pyshell#44>, line 1) 

my last idea was, thought might have been fact windows "translates" few folders, such "users" folder, russian (though typing "users" still correct path), tried in python31 folder. still, no luck. ideas?

the problem string

"c:\users\eric\desktop\beeline.txt" 

here, \u starts eight-character unicode escape, such '\u00014321`. in code, escape followed character 's', invalid.

you either need duplicate backslashes, or prefix string r (to produce raw string).


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -