1. When writing regular expressions, why add re. S
Make the '. ' special character match any character at all, including a newline; Without this flag, '. ' would match anything except a newline.
2. Differences in Search,match,findall in regular matching
The match () function only detects if the re is matched at the start of the string, and search () scans the entire string lookup match, which means that match () is returned only if the 0-bit match succeeds, and if the match is not successful, match () will return none. Search () scans the entire string and returns the first successful match.
The following is an explanation of FindAll in the official document:
Return all non-overlapping matches of the pattern in string, as a list of strings. The string is scanned left-to-right, and matches was returned in the order found. If One or more groups is present in the pattern, return a list of groups; This would be a list of tuples if the pattern have more than one group. Empty matches is included in the result unless they touch the beginning of another match.
3. The common operation of the folder, determine whether to create, do not exist to create, and set the working directory under the current folder
os.path.exists (KEYWORD):
Os.mkdir (KEYWORD)
Os.chdir (KEYWORD)
4. Other common operations
Slice operation: I=i.replace (R "\\\\/","/")
I=i[:-2]
These two steps can be used to complete the substitution of all strings.
Complete the specified dynamic path: file_path=' {0}.{ 1} '. Format (i,' jpg ').
Determine whether a class belongs to a data type:
if isinstance (TEXT,STR) is not Ture
Return None
Debug Log 2 (Python)