1 "" " 2 tuple list distinction: 3 1. tuples wrapped with parentheses; list wrapped bracket; 4 2-tuple immutable; Variable List 5 " "" 6 "" " 7 Creating four ways of tuples . 8 1.tup_1 = () # empty tuples . 9 2.tup_2 =. 1, a tuple element # 10 tup_3 = (2,) a tuple element # . 11 3.tup_4. 1 = 2, 3, a plurality of elements of the tuple # 12 is tup_5 = (l, 2,3) # tuple plurality of elements 13 4. using the type constructors tuple () created or other types of data into a tuple 14 tup_6 = tuple () Create an empty tuple # 15 tup_7 tuple = ([ "a", "B", "C" ]) Into a list of tuples # 16 tuples are determined by commas, parenthesis instead of 17 , for example, the following types, as will be to look neuron progenitor 18 >>> x,y = 1,2 19 >>> x,y 20 (1,2) 21 >>> 12,"ab",34 22 (12,"ab",34) 23 """ 24 # tup_1 = () 25 # print(type(tup_1)) # <class'tuple'> 26 # tup_2 = 1, 27 # print(tup_2) 28 # print(type(tup_2)) 29 # tup_3 = (2,) 30 # print(type(tup_3)) 31 # print(type(tup_3)) 32 # tup_4 = 1, 2, 3, 33 # tup_5 = (1, 2, 3) 34 # Print (tup_4) 35 # Print (tup_5) 36 # tup_6 = tuple () 37 [ # tup_7 tuple = ([ "A", "B", "C"]) 38 is # Print (tup_6) :( # result) 39 # Print (tup_7) # result :( 'a', 'B', 'C') 40 41 is "" " 42 is tuples immutable and can not modify the value of the standard element; 43 is a tuple can not delete a single element , using only variable del deleted tuples 44 is "" " 45 # tup_1 = (. 1, 2,. 3) 46 is # # tup_1 [0] = #. 8 TypeError: 'tuple'object does not support item assignment 47 # del tup_1 48 #Print # (tup_1) # NameError: name 'tup_1' IS Not defined 49 "" " 50 to convert between the type constructor: List (), STR (), tuple () 51 is 1.list () into the list 52 is 2 .str () into a string 53 is '' .join into a string (strings built-in methods, '' represents a new string separated by which a character) 54 is '@'.join as to partition @ , each element into a string of other types of splice 55 3.tuple () into tuples 56 is "" " 57 is # list_1 = [" 123 "," ABC "," Python "] 58 # WORD_1 =" @ " .join (list_1) 59 # Print (WORD_1) # result:Python @ ABC @ 123 60 # word_2 = STR (list_1) 61 is # Print (word_2) # result: [ '123', 'abc ', 'python'] 62 is # Print (type (word_2)) 63 is # list_2 = word_1.split ( "@") 64 # Print (list_2) # result: [ '123', 'ABC', 'Python'] 65 # list_3 List = ( WORD_1) 66 # Print (list_3) # result: [ '1', '2 ', '3', '@', 'a', 'b', 'c', '@', 'p', ' Y ',' T ',' H ',' O ',' n-'] 67 # tup_1 = tuple (list_2) 68 # Print (tup_1) # result (' 123 ',' abc ' ,' python ') 69 # Print (type (tup_1)) 70 # list_4 = List (tup_1) 71 is # Print (list_4) 72 73 is "" " 74 tuple supported actions are: 75 1. subscript index access element 76 2. Use for, while traversing the loop 77 3. The support function len (), max (), min (), tuple () 78 4. Built Method: index (), COUNT () 79 5. The member operator: in / in Not 80 6. The support +, * operation (connection, repeat) 81 "" " 82 # tup_1 = (. 1, 2," A "," B "," C "," A "," B ") 83 # Print (tup_1.index (" B ")). 3 # 84 # Print (tup_1.count (" A ")) # 2 85 # Print (in tup_1. 1) # True 86 87 "" " 88 Range ([Start,] STOP [, EP]) function, characteristics: 89 1 Generally used for cycle 90 2. immutable sequence, generates integral elements 91 3.Start, start, optional, defaults to 0 92 4.stop, end, not optional, must be not included in the sequence of integers generated 93 5.start, closing the left and right open STOP 94 6.step, step, optional, defaults to 1, may be a positive or negative 95 7 + is not supported, the operation * 96 equal 8.range function produced sequences, as long as the same result can range is determined two functions, or unequal 97 9. 8 items, lists, tuples not support 98 10. support member operator in / in not 99 11. The built-in methods: index, COUNT 100 "" " 101 # A Range = (0,. 3, 2) # sequence generated: 0, 2 102 # Print (a) 103 # B Range = (0,. 4, 2) sequence generated #: 0, 2 104 # Print (B) 105 # Print (a == B) True # 106 # list_1 = [1, 2, 3] 107 # list_2 = [3, 2, 1] 108 # print(list_1 == list_2) # False 109 # tup_1 = ("a", "b", "c") 110 # tup_2 = ("c", "b", "a") 111 # print(tup_1 == tup_2) # False 112 # for temp in range(10): 113 # print(temp) 114 # print(5 in range(10)) # True 115 # print(range(10).index(5)) # 结果为:5 116 # print(range(10).count(3)) # 1 117 """ 118 序列:Strings, lists, tuples, Range () 1. Variable: List 119 120 2. immutable: string, a tuple, Range () 121 3. Supported Operating: subscript index, slice, len (), max (), min () 122 4. built each have a different the method, variable names, will pop up the corresponding built-in methods 123 5. a method built up string, followed by a list, tuple least 124 6. conversion functions:. str (), "" join ( ); List (); tuple () 125 "" " 126 " "" 127 two types of random data, dictionary, the set of 128 "" " 129 # name, test scores, save corresponding dictionary