[Learning Record] Python Tips Summary (occasional updates, long-term records)

Source: Internet
Author: User
Tags generator

A lot of grammar is not clear, people and stupid, this life is impossible to memorize, can only record them on the internet, need to come over to check.

6.15

1.enumerate ()

Enter a list or tuple to return an iterator consisting of an ordinal and a value

  

2. Generator expressions

Use parentheses to write to a method similar to a list derivation, which can then be used for loop traversal or use next to return the next value, which will return a stopiteration exception when traversed to the end. You can save space by not calculating the list at the very beginning, but by calling one calculation at a time, but each generator expression is used only once.

  

3.any and all

Any takes a sequence of Boolean values that returns true as long as there is a value of true. All is required to be true only to return true.

  

4.Counter

Need to import functions

 from Import Counter

Used to count the number of elements in a sequence

  

[Learning Record] Python Tips Summary (occasional updates, long-term records)

Related Article

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.