aTuple=("java",77,88,99) print(aTuple) 输出: ('java', 77, 88, 99)
aTuple=("java",77,88,99) print(aTuple) print(aTuple[0]) print(aTuple[1]) print(aTuple[2])
aTuple=("java",77,88,99) print(aTuple) aTuple[0]="Python" print(aTuple) aTuple[0]="Python" TypeError: 'tuple' object does not support item assignment
>>> a = ('a', 'b', 'c', 'a', 'b') >>> a.index('a', 1, 3) # 注意是左闭右开区间 Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: tuple.index(x): x not in tuple >>> a.index('a', 1, 4) 3 >>> a.count('b') 2 >>> a.count('d') 0