-3

I'm trying to implement the next line:

with open('.\numbers.txt', 'r') as f:

The \n in the path is being recognized as the new line special character.

2 Answers2

1

You can use the raw string by prefixing the string with r

print(r'.\numbers.txt')

Or escape the backslashes with \\

print('.\\numbers.txt')
Apollo-Roboto
  • 623
  • 5
  • 21
1

You need to escape the escape character. So

with open('.\\numbers.txt', 'r') as f:

This should work for your needs.

Thanks Scott.

Scotty
  • 11
  • 3