Skip to content

元组是不可变的

元组是不可变的,即一旦创建,就不允许进行修改,任何这样做的尝试都会引发错误。

python
>>> t = ("宝马", "Z4", 2019)
>>> t[1] = "Charger"
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'tuple' object does not support item assignment