Python3 list record and python3list record
#! /Usr/bin/env python3 #-*-coding: UTF-8-*-# Author; Tsukasaname = ['angjiahui', 'liuyueier', 'tabicai ', 'yangruirong '] # create a list print (name) print (name [0], name [1]) # obtain a value print (name []) # Take the range value (slice) print (name [-1]) # print (name [-3:-1]) as the start number on the right of the minus sign # value of the Start number on the right of the negative number * (note that the negative number ranges from right to left) print (name [-2:]) # It can be omitted, indicating the last two values name. append ('yangshuxin') # insert a value and insert print (name) name from the end. insert (0, 'tuskasa ') # insert at the specified position # Python cannot insert data in batches. Repeat insertprint (name) name [0] = 'yyyy' # replace print (name) name. remove ('yyyy') # Delete the specified value print (name) del name [0], # specify the position of the List to delete print (name) name. pop () # Delete the last value of the list. If it is entered in parentheses, name. pop (0) = del name [0] print (name) print (name. index ('shanghaier') # print (name [name. index ('shanghaier')]) # locate the position in the list and print (name. count ('shanghaier') # The same ''' name in the statistics list. clear () # delete a list name. reverse () # Flip list name. sort () # sort the list again. The negative value text name. extend (names) # merge two lists names. copy () # copy a list ''' names = name. copy () # copy a list (note that only the first list will be copied. The list can have more than one name2 = person [:] # full slice (copy) # fully clone import copy # Load module names = copy. deepcopy (name) # deepcopy deep clone print (name) print (names) # list loop ''' for name2 in name: print (name2) ''' name. insert (0, 'tuskasa ') print (name) # Skip loop print (name [0:-]) # Skip the value