Python-- data type common function

1. Index

Support Type

  • str

  • List

Type is not supported

  • int

  • bool

 

= A '1234567' 
Print (A [1:]) where to start reading means # 1 is started from No. 1 element. Default is 0 
Print (A [:]) # extract all elements.

 

2. Slice

Support Type

  • str

  • List

  • Tuple

Type is not supported

  • int

  • bool

 

= A '1234567' 
Print (A [-1:]) # takes the last value 
print (a [4: 6] ) # 4-5 takes two values 
print (a [: 3]) # take 0-2 value 
print (a [1:]) after # 1 takes the value containing the value 1.

 

3. step

 

4. Delete

 

5. Modify

 

6.for cycle

 

7.len

Guess you like

Origin www.cnblogs.com/xinbing/p/11646605.html