What does r’ define in file path

The documentation does a good job:

https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals

If you see a quoted string preceded by a letter, this is a string that has different properties. An ‘r’ preceding a string denotes a raw, (almost) un-escaped string. The escape character is backslash, that is why a normal string will not work as a Windows path string.

1 Like