Life is short, you need Python

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. 
posted @ 2010-08-20 09:21  runfox545  阅读(435)  评论(0编辑  收藏  举报
白月黑羽 Python教程 白月黑羽Python