The difference between Python tuples and lists

1. Tuples are very similar to lists. Most methods are common, but the biggest difference between tuples and lists is that lists can be modified, read, and deleted, while tuples cannot be modified after they are created, and single elements cannot be deleted, but they can be deleted. The entire tuple.

2. But note that if the tuple has only one element, there must be a "," after the element, otherwise the element is still its original type.

3. Although tuples cannot be modified, the query methods supported by the list are basically supported by tuples. It is precisely because tuples cannot be modified, so the query speed of tuples is faster than that of lists.

For the knowledge points of the list, see:

https://blog.csdn.net/wzhrsh/article/details/106344309
https://blog.csdn.net/wzhrsh/article/details/106536211 

Guess you like

Origin blog.csdn.net/wzhrsh/article/details/106558761