Python - Tupple

1. Definition

A tuple is an immutable list. A tuple can not be changed in any way once it is created

>>> TupTest=("Value1","Value2","Value3")
>>> TupTest
(
'Value1', 'Value2', 'Value3')
>>> TupTest[0]
'Value1'
>>> TupTest[2]
'Value3'

Note:

1)It is include by"()"

2)Cannot be changed after it is defined

3)No method(like remove,append,index etc.)

  • You can't add elements to a tuple. Tuples have no append or extend method. 
  • You can't remove elements from a tuple. Tuples have no remove or pop method.
  • You can't find elements in a tuple. Tuples have no index method. 
  • You can, however, use in to see if an element exists in the tuple. 

你可能感兴趣的:(python)