I don't understand, the file is saved with that letter and it turns yellow, tho it only happens with some, and when it turns yellow, it ruins the code and the video doesnt pop up...
Asked
Active
Viewed 274 times
0
-
This is not a letter, this is a tabulation. Your editor is doing syntax highlighting. Add a `r` at the beginning of the string definition – mozway Dec 10 '21 at 18:56
-
Does this answer your question? [Windows path in Python](https://stackoverflow.com/questions/2953834/windows-path-in-python) – Aaron Dec 10 '21 at 18:56
-
basically in normal strings backslash has a special meaning to allow you to type special characters. `\t` is the tab character in this instance. in order to type a literal backslash, you either need to type the escape character first (so type a double backslash `C:\\file\\path`) or, turn off escape characters by using the "raw string" format `r"c:\file\path"`. Finally many python utilities can automatically recognize and convert forward slashes instead: `"c:/file/path"` – Aaron Dec 10 '21 at 18:59
-
that is an escape sequence with a special meaning: TAB – rioV8 Dec 10 '21 at 19:17
1 Answers
2
This is not a letter, this is a tabulation, thus the special syntax highlighting in your text editor:
print('abc\tdef')
output: abc def
Use a raw string by prefixing the string with r
to avoid interpretation of the \t
as tabulation:
print(r'abc\tdef')
output: abc\tdef

mozway
- 194,879
- 13
- 39
- 75
-
Hey! thanks, a lot man! I'm moving to python and OpenCV now since I'm done with Linux so I'm kinda new and I barely know shit, I'm looking forward to exploring this area and mastering it along the way and I think it will be worth my time and it will be fun so once more, thanks, bro! – Gonçalo Lourenço Dec 11 '21 at 12:15