Python list, dictionary, string, collection Carbasalate

Source: Internet
Author: User
Tags python list

#-*-coding:utf-8-*-#List" "Learning Objectives: Additions and deletions can be found through the index, or through the slice lookup, the principle of the slice is left including right does not include" "L= ['Hadoop','Hive','R','ETL','python','R']#take the lastPrintL[1:]#take the second to the bottom .PrintL[1:-1]#step is 1, take onePrintL[0:-1:2]#Step 2, right to leftPrintL[3::-2]" "Count: Count the number of times an element has occurred" "PrintL.count ('R')" "in: To see if an element is in the list" "Print 'R' inchL" "Index : Finds the indexes of an element and, if it occurs more than once, adds" "PrintL.index ('R')" "Increase" "L_1= Range (4)PrintL_1l_1.append (8)PrintL_1" "Delete: There are usually three ways to remove, which is remove (), pop (), and Del (), where the most important thing to note is the pop () Delete method, which can be deleted by the index location, and can also return the deleted value, and then often use" "l_2= Range (10)#Delete a specific valueL_2.remove (6)#Delete by index locationL_2.remove (l_2[0])#pop is deleted by index location and can return deleted valuesA = L_2.pop (3)Printa#del Delete directly, delete multipledelL_2[2]#change: Remove the value of the list and assign the value againL_3 = ['I',' Love',' You']#Mandarin RevisionL_3[1] =' Not Love'#Slice ModificationL_3[1:3] = [' Love',' You']PrintL_3#Reverse: Flashback Print ListL_2.reverse ()Printl_2#SortL_4 = [1, 3, 2, 6, 5]l_4.sort ()

Python list, dictionary, string, collection Carbasalate

Related Article

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.