Python元组
来源:互联网 发布:中国企业网络黄页 编辑:程序博客网 时间:2024/06/05 05:21
元组:不可变序列
一旦定义就不能再修改,使用逗号分隔符进行分割,即使只有一个值,也必须加一个逗号:(42,)
# -*- coding:UTF-8 -*-def read_tuple(): # 创建元组 tuple = ('physic', 'chemistry', 1997, 2000) print tuple[2] tuple1 = (1,2,3) tuple += tuple1 print tuple # del tuple1 # print tuple1 # print tuple[2] # cmp(tuple1,tuple2) 比较两个元组元素 # len() 计算元组元素的个数 # max() 返回元组中元素的最大值 # min() 返回元组中元素的最小值 # tuple(seq) 将列表转换为元组 x = tuple([1,2,3]) print x # output:(1,2,3) x = tuple('abc') print x # output:('a','b','c') x = tuple((1,2,3)) print x # output:(1,2,3) print cmp(tuple1, tuple) # 元组一旦定义就不能再修改if __name__ == "__main__": read_tuple()
0 0
- Python 元组
- Python 使用元组
- Python组元陷阱
- python元组学习
- Python:元组函数
- Python 元组 小结
- PYthon中的元组
- python学习-元组
- python 元组
- Python 元组
- python 元组
- python 元组
- Python元组类型
- Python 元组
- python元组
- Python元组
- python--列表,元组
- Python入门教程--元组
- hdu 1799 循环多少次?(排列组合,思路)
- Spark程序设计——Scala
- 网络基础
- Python列表
- 137.Clone Graph-克隆图(中等题)
- Python元组
- 《MySQL相关文章索引(2)》
- Python字符串
- # IntelliJ IDEA 2016.2.4 注册码 破解 激活教程
- 移动端获取数据列表
- 关于ListView优化陋解
- 听课学习方法
- html感染型病毒
- Maven一些报错问题