Python tuple()

Python tuple()

Similar list (as a container)
features: immutable objects, the contents of the tuple cannot be added, deleted, or modified, and any data type can be stored.

     列表                                    元组
      []                                     ()
      [1]                                    (1,)
      [1,2,3]                                (1,2,3)

Insert picture description here

Insert picture description here

Tuples cannot be added, deleted, or modified, but can be queried: subscript index, slice [:]
Insert picture description here

Insert picture description here

If the tuple contains variable data types, you can modify the contents of the tuple indirectly
Insert picture description here

Insert picture description here

Other functions in the tuple: t4.index(5), t4.count(5)

Guess you like

Origin blog.csdn.net/qq_44994799/article/details/109679305