0

When I open a file from a specific folder the Backslash convert the first char of the file name to "x0" and compiler handle the code as escape sequence such as :

file = open("D:\python1\venom.txt")

and the output will be :

OSError: [Errno 22] Invalid argument: 'D:\\python1\x0benom.txt'
Fady Esam
  • 31
  • 1
  • 7
  • 3
    Same mistake, You should use ```r"D:\python1\venom.txt"``` or ```"D:\\python1\\venom.txt"``` or ```"D:/python1/venom.txt"```. ```\v``` is an escape sequence for "ASCII Vertical Tab (VT)" –  Aug 24 '21 at 03:02
  • See https://stackoverflow.com/questions/26184100/how-does-v-differ-from-x0b-or-x0c –  Aug 24 '21 at 03:04
  • thank you I tried the first and it's work – Fady Esam Aug 24 '21 at 03:05

0 Answers0