Often when you define a variable, access data, or save the results of a tool, you need to reference a specific file or data path. In a traditional Windows environment, this typically requires you to define the path using backslashes. For example, you have been accessing the data and exercises for this book by going to C:\Student\IntroArcPro. This is an example of a path.
Unfortunately, you cannot use this common method of defining a path within a Python script. Backslashes are reserved characters within Python that are used to indicate an escape or line continuation. So, when specifying a data path, you must use a different method. Python supports three methods for defining a path:
- Double backslashes: C:\\Student\\IntroArcPro
- Single forward slash: C:/Student/IntroArcPro
- Single backslash with an r in front of it: r"C:\Student\IntroArcPro"
You can use either of the preceding methods...