pthon Basics (index, slice, sequence of addition, multiplication whether the check element is a member of the sequence, sequence length is calculated, maximum and minimum)

Sequence data storage data structure

python

Lists, tuples, dictionaries, collections, strings

sequence:

Storing a plurality of values ​​for a contiguous memory space, and arranged in a certain order, or by an index value

 

Index (number):

Indices may be negative

Left to right, starting from 0

From right to left starting at -1

 

slice

List name [start value: End value: step]

Start value from 0

End value required to obtain bits +

Step bit without writing 0

 

Sequences are added

2 + 1 sequence Sequence 1 Sequence 2 Sequence =

Only the same type of sequences are added

List + List

+ Tuples tuple

String + String

 

Sequence multiplication

* = Multiplier sequence is repeated N times in sequence

The content of the sequence is repeated N times

 

Check whether an element is a member of the sequence

Keyword in sequence

Keywords not in sequence

 

Calculated sequence length, maximum, minimum 

len () length

max () maximum

min () Min

list () is converted to the sequence list

str () converts the string

sum calculation and

sorted () to sort the elements

the reversed () inverted sequence elements

the enumerate () sequence into the sequence index

 

Guess you like

Origin www.cnblogs.com/zhangjiantaocs/p/11770584.html