0
Syntax Error in opening an .txt file using Python open() function
Syntax Error in opening an .txt file using Python open() function in PyCharm IDE and IDLE also.I wrote following code file = open("C:\Users\Umang Goswami\Dekstop\Python File reading.txt","r") cont=file.read() print(cont) file.close() All code is as per SoloLearn lesson at https://www.sololearn.com/learn/Python/2446/ . SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape Process finished with exit code 1 Plz tell why code is not working , I am preety excited about this program.
3 ответов
+ 3
Avoid spaces in the file name 🤔
And if you can, then avoid that in path also!
+ 1
Thanks problem solved by replacing \ with /
0
I copy pasted that error and got a thread on stackoverflow for the same problem ,
https://stackoverflow.com/questions/37400974/unicode-error-unicodeescape-codec-cant-decode-bytes-in-position-2-3-trunca