Python basis week2

This Section

  1. Lists, tuples operation
  2. String Manipulation
  3. Dictionary operations
  4. Set operations
  5. File Operations
  6. Character encoding and transcoding 

1. list of tuples operation

After the list is one of our most common data types, the data can be achieved most convenient store, modify and other operations by list

Definition list

1
names  =  [ 'Alex' , "Tenglan" , 'Eric' ]

By indexed access elements in the list, index counts from 0

1
2
3
4
5
6
7
8
>>> names[ 0 ]
'Alex'
>>> names[ 2 ]
'Eric'
>>> names[ - 1 ]
'Eric'
>>> names[ - 2 #还可以倒着取
'Tenglan'

Slice: taking a plurality of elements  

Guess you like

Origin www.cnblogs.com/meige2006/p/12374978.html