Debug Log 2 (Python)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.