问题
Is there any way without typing r
or 'double slash' to resolve this problem.because this two tricks change the type of file:
f = open('C:\Users\alireza\Desktop\exersices.python\p5.files\1.txt')
Error:
File "<ipython-input-1-243f8d6a931c>", line 1
f = open('C:\Users\alireza\Desktop\exersices.python\p5.files\1.txt')
^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
回答1:
This will solve your issue.
f = open('C:/Users/alireza/Desktop/exersices.python/p5.files/1.txt')
来源:https://stackoverflow.com/questions/52243287/error-with-back-slash-in-python-open-statement