First, the "/" left tilt is a forward slash, "\" Right tilt is a backslash, can be written as follows: Division is a forward slash in general for directory separators, UNIX and web with forward slash/,windows with backslashes, but now windows
(i) the slashes in the catalogue
The directory parameters to be entered in the Python read file are listed in the following example:
Path = r "C:\Windows\temp\readme.txt"
path1 = r "C:\windows\temp\readme.txt"
path2 = "C:\\windows\\temp\\readme.txt"
Path3 = "C:/windows/temp/readme.txt"
The arguments in open () of the file function can be either path or path1, path2, Path3.
Path: "\" is a special character in a string, plus r changes to the original string, then the string escapes "\ t", "\ r"
Path1: Case does not affect Windows navigate to file
Path2: Use a "\" to cancel the special escape function of the second "\", namely "\"
Path3: Using a forward slash as a directory separator can also go to the corresponding directory, and in Python the way the PATH3 also eliminates the backslash \ escaped annoyance
(ii) the slashes in regular expressions
The regular expression matches the backslash "\", Why is "\\\\" or "R" or "\"?
Because in regular expressions \ is a special symbol, in order to cancel its special meaning in regular expressions need to add a \ to become a \, but the problem again, \ is also a special character in the string, so you have to two to cancel its special meaning, that is \\\\. Python has an original string operator for special characters in those strings that have no escape characters and cannot be printed in the original string. This allows you to cancel the escape function in the string, that is, r "\".
The above mentioned is a small set of Python to introduce the left Slash, right slash (forward slash and backslash), I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!