List: list

Coding _ * _ #: _ * _. 8 UTF- 
# OF: Dian Yuan Wang
# Date: 2019/12/7
'' '
Data Type
Integer
String
list, a tuple
name =' wuchao '
name =' Jinxin '
name =' Xiaohu '
name = 'sanpang'
name = 'Ligang'
'' '

# list Create: to create a list by bracket
A = [' wuchao ',' Jinxing ',' Xiaohu ',' sanpang ',' Ligang ']
# CRUD
# Find .count number query appears
# .index: query element corresponding to subscript
# in: there is a query whether the content list

# Print (a [. 3])
# # search slice
# print (a [1: 4 ]) # take the first index, to the end of the third index
# print (a [:]) # take all list
# print (a [1: -1 ]) # all take a value other than the last value
# print (a [ 1: -1: 1]) in each number #a is meanings: the first one is represented by the subscript 1 starts, the second -1 for taking other than the last one, represents a third step (interval),A negative value indicates the positive value of the order of left \ right
# Print (A [. 1: -1: 2]) # taken from left to right
Print # (A [:: -. 1])
# B = A [:: -. 1]
# Print (A, B)

# increasing insert: the data into an arbitrary position, it is necessary to tell which position append: additionally, the last position extend : the two lists hebing
# # a.append ( 'Xuepeng')
# a.insert (. 1, 'Xuepeng')
# Print (A)
#
# # Review: query by extraction, and then assign
# a [1] = ' haidilao '# single data fetch
# a [1: 3] = [' dery ',' lining '] # plurality of data modification
# Print (a)

# remove
# remove: remove entries in the list indicates, the input required to remove specific content
# pop: delete the corresponding index values
# del: deletion method other than the list
# a.remove ( 'Jinxing')
# del a [0]
# Print (a)

# calculations list, the number of occurrences of an element
# = B [l, 2,3]
# content list two superimposing method: Extend
# a.extend (B)
# print (a, B)

#index method: the list of elements the subscript, to find the position based on the content
# print (a .index ( 'jinxing'))

#reverse Method: The table of contents arranged in reverse sort: Sort
a.reverse ()
Print (A)
a.sort ()
a.reverse ()
Print (A)

Guess you like

Origin www.cnblogs.com/python-beginner/p/12000433.html