0

variable (str)

I want to give the value of the variable the address of the file but nothing succeeds I enter: r="C:\Users\User\Desktop\Promo.txt" error: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape Where was I wrong?

8th May 2017, 4:55 PM
Kreez
Kreez - avatar
1 Antwort
+ 2
In Python the character '\' have special meaning inside a string to remove that meaning prepend the string with the character 'r': r = r"C:\Users\User\Desktop\Promo.txt" Another way is to escape the '\' with another one: r = "C:\\Users\\User\\Desktop\\Promo.txt"
8th May 2017, 5:05 PM
Ulisses Cruz
Ulisses Cruz - avatar