Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> Python

Biểu diễn immutable vectors trong Python

Dùng tuple làm immutable vector. Tuple immutable, ordered, nhanh hơn list.

Ví dụ

myVec = (10, 15, 21)
myVec[0] = 10  # TypeError: tuple immutable