Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Python raw strings

'''
Windows paths for files contain backslashes which python interprets as
escape sequences. To ignore these escape sequences, you can use raw strings!
'''

import os

# os.chdir changes the current working directory
os.chdir("C:UsersUSERNAMEDesktop") # Creates error

INSTEAD, USE:
os.chdir(r"C:UsersUSERNAMEDesktop") # Add an r before the string
Source by www.journaldev.com #
 
PREVIOUS NEXT
Tagged: #Python #raw #strings
ADD COMMENT
Topic
Name
5+2 =