Study notes (9): Zero-base mastering Python entry to actual combat-which one should I use for lists and ancestors? (three)

Learn now: https://edu.csdn.net/course/play/26676/338779?utm_source=blogtoedu

Tuple: () Create a tuple

tuple() creates a tuple

The elements in the tuple are separated by commas, and any type of element can be used.

To create a tuple with only one element, you must add a comma after the element. If no comma is added, an addition string is created.

Tuples are also sequences.

Sequence: tuple, list, string.

The difference between a tuple and a list: the elements in a tuple cannot be modified, but the elements in a list can be modified.

Tuples are immutable objects, and lists are mutable objects.

Convert tuples into lists and modify elements. Then the list is converted back to a tuple, and the elements in the tuple can be modified.

The calculation speed of tuples is fast.

Both are container and sequence objects.

 

 

 

Guess you like

Origin blog.csdn.net/m0_49939521/article/details/108530162