Python Growth notes

Source: Internet
Author: User

Regular expressions

1. Select a match: Pipe symbol (|), which means " choose one from multiple modes ". Example:at|home à at,home

2. dot matches any character except line break

3. boundary match:\b matches the boundary of a word;\b matches in the middle of a word, which is not the word boundary.

4. Character set: matches any character that is contained in the square brackets. applies only to single-character cases . Example:[ab] àa,b

5. An asterisk (*) matches 0 or more occurrences of its left side

A plus (+) match occurs one or more times

Question Mark (?) Match 0 or one occurrence

6. Character Set special character:\d to match any decimal number

                              \w The character set

that represents all letters

\s represents a space character

Note: The uppercase representation of special characters does not match, example:\d represents any non-decimal digits

!--[if!supportlists]-->7. parentheses specify grouping and matching subgroups, for example: (\w+)-(\d+)

!--[if!supportlists]-->8. match objects: group () and groups ().

!--[if!supportlists]-->9.group (): either return the entire match, or return a specific subgroup as required; groups () returns only one tuple that contains a unique or all child group.

!--[if!supportlists]-->10. !--[Endif]-->match () and search () Difference: match () starts from the beginning of the string, search () will not only search the starting part, but strictly search the string from left to right.

!--[if!supportlists]-->11. !--[Endif]-->findall () The full non-repetition of a regular expression pattern in the query string, the returned is a list .

!--[if!supportlists]-->12. The!--[Endif]-->finditer () is with findall ( similar but more memory-saving entities. Difference: .

!--[if!supportlists]-->13. The!--[Endif]--> search and replace: Sub () and subn ()

  is some form of substitution for all the parts of a string that match a regular expression. Difference:subn () also returns a total number that represents the substitution.

Function

!--[if!supportlists]-->1.*args

!--[if!supportlists]-->2.**kwargs dict form

3. Parameters:

Normal parameters: Pass the arguments to the formal parameter in strict order

Default parameter: Must be placed at the end of the parameter list

Specify parameter: assigns a parameter to the specified formal parameter

Dynamic Parameters:* Default incoming parameters, all placed in tuples

                ** default incoming parameters, all placed in the dictionary

Universal parameters: *args, * * Kwargs

!--[if!supportlists]-->4.python .

5. variables:

Global variables, all scopes are readable.

To re-assign a global variable, you need global, such as:Global name

Special, the list, dictionary, can be modified, but not re-assigned value.

Global variables are uniformly capitalized.

6. a shorthand for the if else for ternary operations (Trinocular operations)

Example: Name = ' Alex ' if  1==1  Else ' SB '

  

Python Growth notes

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.