1.创建一个元组并给它赋值
>>> aTuple = (123,'abc',4.56,['inner','tuple'],7-9j) >>> aTuple (123, 'abc', 4.56, ['inner', 'tuple'], (7-9j)) >>> tuple('ABC') ('A', 'B', 'C')
2.访问元组中的值
>>> aTuple[0] 123 >>> aTuple[1:4] ('abc', 4.56, ['inner', 'tuple']) >>> aTuple[:3] (123, 'abc', 4.56) >>> aTuple[3][1] 'tuple'
3.更新元组
元组和字符串一样,是不可变类型,不能更新或者改变元组的元素
4.移除一个元组以及元组本身
删除一个单独的元组元素是不可能的,可以用del语句删除一个元组
5.元组操作符和内建函数
标准类型操作符、序列类型操作符和内建函数和列表的相似
6.元组的特殊特性
3个标准的不可变类型——数字、字符串和元组字符串
元组类型包含的可变对象是可以改变的,比如元组中包含一个列表
7.默认集合类型