Tuples （tuple） It's not just an immutable list
In many Python Tuples are treated as immutable lists in our textbooks , In fact, tuples are more than that , There's another big effect , Represented as record data without a record name . This method of use is often overlooked by people , Leading to a widespread lack of awareness of its role .
Tuples as records
When you use tuples as records , Each item in the tuple is treated as a field , The position of the field indicates its meaning . such as （ full name , Sex , Education ）, The first term of this tuple is a name , All data records must be arranged in this order . If you just use tuples as immutable lists , How many items are there in a tuple , Or the order of each item is not so important . But you look at tuples as record data , It can't be like this . If one item is missing from the record , Then the corresponding item has no value , The records displayed in this way will be incomplete . Or each time the data is arranged in a different order , So when you display the recorded data in tabular form , It won't be accurate .
Here's an example of how to use it as a record , The elements of these tuples cannot be rearranged , Otherwise, the information will be confused ：
>>> lax_coordinates = (33.9425, -118.408056) >>> city, year, pop, chg, area = ('Tokyo', 2003,