Redis persistence (RDB, AOF, RDB and AOF mixed)

2023-01-03   ES  

List is represented by [], which is the most frequent and most common composite data type in Python.

The positive and reverse index in the

列 Each element in the list is variable (modified, deleted)
列 List is orderly, you can use indexes to access the specified element

The element in the
表 can be any object in Python, it can be a string, integer, a group, or a list
列 Cut in the medium value of the list can be used for variable [head bidding: tail bid], from left to right default 0, from right to left index default-1, the bid can be expressed as the head or get the head or the head or the head or the head or the head or the head or tail
9 + is a list connection operator, star number * is repeated operation

basic operation

list = ['play', 'algorithm', 'python', 2019, 12.02, 'python']
author_list = ['Tommy', 'ChaoChao', 'Wsqstar']

  • Positive number operation, intercept the right side of the colon
Print ('Full List List:', List) 
 Print ('Second element list [1]:', list [1]) 
 Print ('Second to Fourth Element List [1: 4]:', List [1: 4]) 
 Print ('Third to the last element List [2:]:', list [2:])
  • Inconsistent operation, intercepting the right side of the colon
Print ('The second element List [-2]:', list [-2]) 
 Print ('The last three elements list [-3:]:', list [-3:]) 
 Print ('The second to the fourth element List [-4: -1]:', list [-4: -1])
  • Operation
Print ('Output List Two Author_List * 2:, Author_list * 2) 
 Print ('two list combinations list + author_list:', list + author_list)
  • whether the element exists in the list
Print ('Python is in the list:', 'python' in list)
  • iteration
Print ('iteration output Author_list each item:') 
 for item in author_list: 
     Print (item)
  • Output results
Full list list: ['play', 'algorithm', 'python', 2019, 12.02, 'python'] 
 The second element list [1]: Algorithm 
 The second to the fourth element List [1: 4]: ['Algorithm', 'Python', 2019] 
 The third to the last element List [2:]: ['python', 2019, 12.02, 'python'] 

 The second element list [-2]: 5.11 
 The last three elements list [-3:]: [2019, 12.02, 'python']] 
 The second to the fourth element List [-4: -1]: ['python', 2019, 12.02] 

 Output list twice Author_list * 2: ['Tommy', 'ChaoChao', 'WSQStar', 'Tommy', 'Chaochao', 'WSQStar'] 
 Two list combinations + author_list: ['play', 'algorithm', 'python', 2019, 5.11, 'python', 'tommy', 'chaochao', 'wsqstar'] 

 Whether python is in the list: true 

 Each item of iterative output Author_List: 

Basic function

list = ['PLAY', 'Algorithm', 'Python', 2019, 12.02, 'Python'] 
 int_List = [12, 22, 30, 13, 24, 1, 10, 10.3, -1] 

 Print ('List length len (list):', len (list))
  • max () and min () functions only support the list elements of the list and float that can calculate the value of the value
Print ('maximum value Max (int_List):', max (int_List)) 
 Print ('minimum value min (int_List):', min (int_List))
  • Quickly turn a object to list
Print ("STR object to list list ('tommy'):", list ('tommy'))
  • Output results
List length len (list): 6 
 Max (int_List): 30 
 Minimum value min (int_List): -1 
 STR objects turn to list list ('tommy'): ['t', 'o', 'm', 'm', 'y', 'y']
  • basic method

list = [‘play’, ‘algorithm’, ‘python’, 2019, 12.02, ‘python’]
author_list = [‘Tommy’, ‘ChaoChao’, ‘Wsqstar’]



list.insert(5, ‘Baidu’)




Print (“Remove an element, default the last element list.pop ():”, list)

list.pop ([Index = -1]) method is the same as Del. The following example can also be used in Del list [0] 
 Print ("Remove the first element list.pop (0):", list) 

 list.reverse () 
 Print ("The list element reverse list.reverse ():", list) 

 Print ('' List sort, it is recommended to check the rookie tutorial to get a better description: ',' ')))) 

 list2 = list.copy () 
 Print ("list copy, I am list2 list.copy ():", list2) 

 list2.clear () 
 Print ('list2 after clearing list2.clear ():', list2) 
 # Copy and use = different assignments, copying a new list, any operation of List2 does not affect List 
 Print ('list2 List:', list) 

 # When using = assignment, all operations will affect the list itself 
 list3 = list 
 Print ('I am a List3: ', List3) 
 list3.clear () 
 Print ('list3 after clearing list3.clear ():', list3) 
 Print ('List3 is clear after empty:', list)
  • output results
Add new object list.append (Author_List) at the end: ['Play', 'Algorithm', 'Python', 2019, 5.11, 'Python', [Tommy ',' Chaochao ',' WSQStar ']] 
 Remove the first matching of a certain element list.remove (author_list): ['play', 'algorithm', 'python', 2019, 5.11, 'python'] 

 Add new object list.insert (5, 'Baidu') at the specified location: ['PLAY', 'Algorithm', 'Python', 2019, 5.11, 'Baidu', 'Python'] 
 Add the value in the batch to the end of the list to the end of list.extend (author_list): ['play', 'Algorithm', 'Python', 2019, 5.11, 'Baidu', 'Python', 'Tommy', 'CHAOCHAO', 'Wsqstar'] 

 Statistically, the number of times that a certain element appears in the list list.count ('python'): 2 
 Find out the index position of a certain element List.index ('python'): 2 

 Remove an element, default the last element list.pop (): ['play', 'algorithm', 'python', 2019, 5.11, 'Baidu', 'Python', 'Tommy', 'Chaochao'] 
 Remove the first element list.pop (0): ['Algorithm', 'Python', 2019, 5.11, 'Baidu', 'Python', 'Tommy', 'ChaoChao'] 

 Reverse list.reverse (): ['chaochao', 'tommy', 'python', 'baidu', 5.11, 2019, 'python', 'algorithm'] 
 List sorting, it is recommended to check the rookie tutorial to get a better description: 

 List copy, I am the list2 list.copy (): ['chaochao', 'tommy', 'python', 'baidu', 5.11, 2019, 'Algorithm']] 
 List2 after clearing list2.clear (): [] 
 List2 after empty listing: ['chaochao', 'tommy', 'python', 'baidu', 5.11, 2019, 'python', 'algorithm']] 

 I am a List3: [Chaochao ',' Tommy ',' Python ',' Baidu ', 5.11, 2019,' Python ',' Algorithm ']] 
 List3 after clearing list3.clear (): [] 
 List3 after empty listing: []


Related Posts

1-8 Linux system

Installing GDAL library always prompts Microsoft C ++ 14.0 or management authority issues

Oracle Clob field Insertation The character is too long

$ .ajax 2.0 Error “Uncaught Typerror: Illegal Invocation” Calla

Redis persistence (RDB, AOF, RDB and AOF mixed)

Random Posts

bzoj 2822 [ahoi2012] Tree House Passenger Cartran Number

java implementation of unicode and Chinese mutual conversion

List collection The same object (one or more attributes) in the collection of attributes returns the list and is sorted and output PSY according to the object attribute

notebook computer connection HDMI interface extension display does not respond

Redis releases the subscription method master