Python - Literals & 'r'
To avoid the interpretation of characters as special characters, the character, r , is added before the opening quote for the string as shown in the following example.
print('C:\path\name') # here \n means newline!
C:\path
ame
print(r'C:\path\name') # note the r before the quote
C:\path\name
OR
print('C:\\some\\name') # '\' means use literally
C:\some\name
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.