62 words
1 minute
Tuple

📌 元组(Tuple)#

A tuple is an ordered and immutable collection of elements.

Features:

  • Ordered
  • Immutable (cannot be changed after creation)
  • Can contain different data types

Example:

t = (1, 2, 3)

Single-element tuple:

t = (5,)

Tuples are immutable:

t[0] = 10 # Error

🔹 Tuple vs List#

TupleList
符号()[]
是否可修改❌ 不可改✅ 可改
用途固定数据可变数据
Tuple
https://lxy-alexander.github.io/blog/posts/python/tuple/
Author
Alexander Lee
Published at
2026-03-01
License
CC BY-NC-SA 4.0