Python 013 study notes

Lists, dictionaries, tuples

List, run out of steam

# List [] 
# CRUD

names = [ 'Alex', 'Bill', 'Candy', 'David', 'Edison']
# List of internal index [0,1,2,3,4,5]

# Take all the elements, corresponding to a complete copy of
Print (names [:])
# take a single element, from 0 starts, represents a
Print (names [ 0])
# slice, a plurality of elements, the default left to right
Print (names [ . 1: . 4])
# get to the last element, blank, which at the end, the default step size . 1
Print (names [ . 1:])
# taken to the second last, negative, indicates the reciprocal, rounding a penultimate
Print (names [ . 1: - . 1])
# taken to the second last, penultimate a rounding, as defined step 2
Print (names [ . 1: - . 1: 2])
# a first default start discarding a penultimate
Print (names [: - . 1])
# taking the inverse of a
Print (names [- . 1:])

# custom value direction, from a first countdown starts, from right to left, in steps of 3
Print (names [- . 1 :: - . 3])
# from the values defined direction starting from the first down, right to left, all the elements in reverse order
Print (names [:: - . 1])
# custom value direction, a first countdown starting from right to left, in steps of . 3
Print (names [:: - . 3])

 

Guess you like

Origin www.cnblogs.com/wtzxxy/p/12388370.html