alireza.mohammadi
alireza.mohammadi

Reputation: 11

Error with back slash in python open statement

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

Upvotes: 1

Views: 1510

Answers (1)

Praveenkumar Beedanal
Praveenkumar Beedanal

Reputation: 834

This will solve your issue.

f = open('C:/Users/alireza/Desktop/exersices.python/p5.files/1.txt')

Upvotes: 2

Related Questions