Python3 list record and python3list record

Source: Internet
Author: User

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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.