Tuples are enclosed in parentheses and cannot be modified. The list is enclosed in brackets and can be modified. Lists can be nested in the list, tuples can be nested tuples, generally no one to mix, this test is correct: [Python] View plain copy>>> aa[0] (a) >>> aa[0]= (All) Tracebac K (most recent): File "<stdin>", line 1, in <module> TypeError: ' Tuple ' object does Item Assignment >>> aa[0][0] >>> aa[0][0]=34 Traceback (most recent call last): File "<stdi N> ", line 1, in <module> TypeError: ' Tuple ' object does not the support item assignment However, a dictionary was used during the paint process, and the value of the tuple was inadvertently modified : [Python] View plain copy>>> pos = {0: (3), 1: (+, +), 2: (+),: (+), 4: ()} >>> ; POS {0: (1), 2: (+, +), 3: (+), 4: (+)} >>> pos[0]= (+) >>> pos {0: ( 1, 2), 1: (+), 2: (+), 3: (+), 4: (+)} >>> then found this in the reference manual of the dict search: [python] View plain copy> >> a = Dict (one=1, two=2, three=3) >>> B = {' One ': 1, ' both ': 2, ' Three ': 3} >>> c = dict (Zip ([' One ', ', ', ' three '], [1, 2, 3]) >>> d = dict ([' One ', ' 1 ', 2) ' (' Three ', 3)]) >> > E = dict ({' Three ': 3, ' one ': 1, ' One ': 2}) >>> A = = b = = C = = d = e True means that in the dictionary value value is enclosed in parentheses, brackets, curly braces , its value can be modified. Another misleading reference is the relationship between tuples and parentheses in Python, where tuples are determined by commas, not parentheses. As you can see, even if you don't have parentheses, you're a tuple. [Python] View plain copy>>>a= ("One", "one") >>>a[0] ' one ' >>>b= ("one") >>>b[0] ' o ' >>>c= ("One",) >>>c[0] ' one ' >>>d= "one", >>>d[0] one top
Brother Lian Learning Python (----) the misleading of tuples and parentheses