Reputation: 7681
When giving file paths to a Python script I find myself constantly having to manually double slash the file path (because of escape characters). My question: is there an in-built python function/class/method that either signify escape characters do not apply to the string in question or will simply double slash the paths for me?
i.e.
D:\MPhil\Model_Building\Models\TGFB\Vilar2006\Another_Fit_test\Fit15
into:
D:\\MPhil\\Model_Building\\Models\\TGFB\\Vilar2006\\Another_Fit_test\\Fit15
Upvotes: 0
Views: 79
Reputation: 2564
You can prefix your string with r like this:
some_path = r"escape\codes\will\be\bypassed"
Upvotes: 5