List usage, list usage
I learned from my teacher and tried to write this experiment.
Import copy
Names = ["CSCF", "MGCF", "HSS1", "HSS2", "HBSBC01", "EMA"]
'''
Print (names)
Print (names [0], names [2])
Print (names [])
Print (names []) # Get to 3 Excluding 3 starting position including end position not included, also known as Gu head regardless of the end
Print (names [-1]) # obtain the last one
Print (names [-2]) # Take the second to the last
Print (names [-3:-1]) # the start position is left to right.
Print (names [-2:]) # Get from-2 to the end
Print (names [0: 3]) # Get from scratch 3 Excluding 3
Print (names [: 3]) # Get from scratch 3 Excluding 3
Names. append ("EDB") # append "EDB" to the end"
Names. insert (1, "These") # insert to the beginning of 1
Names. insert (3, "hbsbc01") # insert to the front of HSS1
Names [3] = "P-CSCF" # Replace hbsbc01 with a P-CSCF
Print (names)
'''
# Delete
'''
Names. remove ("these") # Delete the specified content
Del names [2] # Delete specified subscript content
Names. pop () # by default, no subscript is used to delete the last one.
Print (names)
'''
# Search
'''Print (names. index ("MGCF") # locate the position subscript of MGCF
Print (names [names. index ("MGCF")]) # I don't know how to use it.
# Duplicate name statistics:
Names. insert (1, "These ")
Names. insert (1, "These ")
Names. insert (1, "These ")
Print (names)
Print (names. count ("these") # count the number of "these" in this array
Names. reverse () # reverse the entire array
# Names. clear () # clear the entire array
Names. sort () # sort by ascii code
Print (names)
'''
# Extension
'''
Names2 = [1, 2, 4, 5]
Names. extend (names2) # extend names2 to the end of names
Print (names)
Del names2 # Delete the entire names2
Print (names. names2)
'''
# Copy
'''
Names3 = names. copy ()
Names [3] = "may"
# Names = ["mgcf", ["a", "B"]
# Names [1] [0] = "mgcf1"
Print (names)
Print (names3)
'''
Names = ["CSCF", ["MGCF1", "MGCF1"], "HSS1", "HSS2", "HBSBC01", "EMA"]
Names [1] [1] = "MGCF2"
Names3 = copy. copy (names) # this is also a shortest copy that equals to copy
Names3 = copy. deepcopy (names) # The result of deep copy is two independent data.
Names [2] = "hss01"
Names [3] = "hss02"
Print (names)
# Names3 = copy. copy (names)
Print (names)
Print (names3)
Print (names [0:-]) # print Step 2
Print (names [: 2]) # Step 2 print another method
Print (names [:]) # print all data, but generally no one writes it like this.
For I in names: # print one by one
Print (I)