Lưu ý: Bản dịch của mục này hiện đang được kiểm tra chất lượng, vì vậy một số nội dung tạm thời chỉ hiển thị bằng tiếng Anh.
Mục từ này chưa được dịch sang ngôn ngữ của bạn, vì vậy nội dung gốc được hiển thị bên dưới.
tuple
This term is primarily used in technical registers, specifically within mathematics, computer science, and database management. It describes a fixed-size collection of elements where the order of the items is significant. In programming, it often contrasts with a list or an array by being immutable, meaning its contents cannot be changed after creation.
In the context of relational databases, a tuple is the formal term for a row or record. While a table is a set of tuples, each individual tuple represents a single entity or instance of the data structure defined by the table's schema.
Ý nghĩa
Ví dụ
You can use a tuple to store a fixed set of values that should not change.
Wait, did you define this as a list or a tuple?
The API returns a 3-tuple consisting of a status code, a message, and a timestamp.
I need to unpack this tuple into three separate variables.
A tuple is immutable, meaning you cannot add or remove elements after it is created.
The database query returns each record as a tuple of strings.
Let's represent the player position as a 2-tuple of x and y coordinates.
I wonder if using a named tuple would make the code more readable.