"3" Python core programming chapter sixth-sequence: strings, lists, and tuples

Source: Internet
Author: User

1. Sequence type operator
1 Sequence operator Action 2 Seq[ind] Get the element labeled IND 3 Seq[ind1:ind2] Gets the set of elements from Ind1 to Ind2  4 seq * expr sequence repeats expr times 5 seq1 + SEQ2 connection sequence seq1 and SEQ26 in seq Determines whether the obj element is contained in the SEQ 7 not in SEQ to determine if the obj element is not included in the SEQ

2. Built-in functions available for sequence types

1 functions of function names2 Enumerate (ITER) takes an iterative object as a parameter and returns a enumerate object (same as3 Is also an iterator) that generates an index value for each element of the ITER4A tuple that consists of the item value (PEP 279)5 len (SEQ) returns the length of the SEQ6Max (Iter,key=none)or7Max (arg0,arg1...,key=None) b return to ITER or (Arg0,arg1,...) The maximum value in the, if key is specified,8 This key must be a return to the sort () method for comparison.9 tuning function.TenMin (ITER, Key=none)or OneMin (arg0, arg1 .... key=None) returns the minimum value inside ITER, or returns (Arg0,arg2,...) The minimum value inside, if you specify a key, the key must be a A The sort () method that is used to compare the callback function. -Reversed (SEQ) c takes a sequence as a parameter, returning an iterator that is accessed in reverse order (PEP 322) - Sorted (ITER, theFunc=None, -key=None, -Reverse=False) c takes an iterative object as an argument, returns an ordered list; optional parameters - the meaning of Func,key and reverse is the same as the parameter meaning of the List.sort () built-in function. + Sample. -SUM (seq, init=0) A returns the sum of the SEQ and optional parameter init, which has the same effect as + reduce (operator.add,seq,init) A zip ([it0, It1,... ItN]) d returns a list whose first element is It0,it1,... These elements are the first atAn element consists of a tuple, a second ..., and so on.

"3" Python core programming chapter sixth-sequence: strings, lists, and tuples

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.