0. Description
A sequence is a generic term for some of the data types of python, such as strings, lists, and tuples, which are collectively referred to as sequences because their members are arranged in an orderly manner and can be accessed by the subscript offset to one or more of its members .
The idea is to first introduce the operators and the built-in functions that apply to all sequence types, and then describe each of these sequence types separately .
1. Sequence
Sequence types have the same access pattern: Each of its elements can be obtained by specifying an offset, and multiple elements are obtained by slicing the operation . In the python sequence, the rules for offsets are as follows (assuming the sequence length is N):
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/7D/92/wKiom1bq3yyQV70pAAAP0Jc09p0317.png "title=" Drawing-blogs using the. png "alt=" Wkiom1bq3yyqv70paaap0jc09p0317.png "/>
(1) Standard type operator
The standard type operators are described in the Python review and Collation 2:python objects, which are generally applicable to all sequence types.
(2) Sequence type operator
The following are presented separately:
for a string, it is to determine whether the character is in the string (in fact, this character is also a string object), for lists and tuples, is to determine whether the object belongs to the sequence of objects, for example, as follows:
>>> myList = [' xpleaf ', ' leaf ', ' cl ']>>> ' xpleaf ' in mylisttrue>>> ' cl ' not in Mylistfalse
Repeat Operator: *
Slice operator: [],[:],[::]
Slice operation extension: Using the step index
More on the slice index
This article is from the "fragrant fluttering leaves" blog, please make sure to keep this source http://xpleaf.blog.51cto.com/9315560/1752376
Python Review and Collation 4: Sequence (string/list/tuple)