Python:tuple
来源:互联网 发布:fft算法的作用 编辑:程序博客网 时间:2024/06/06 18:44
元组是不能改变元素的列表;创建时用的是小括号;访问也一样t[1]、t[:3]、t2=t[:]
当单个元素时,记得加逗号:t=(1,) t=1,
创建空元组:t=()
8 * (1,)
由于元组不能添加,插入可以利用切片方法:temp=temp[:2] + ('a',) + temp[2:]
删除元素也用切片方法
修改也不可以
del t 删除元组,当然python也有回收机制
>,in not in,and 这三类也可以用于tuple
>>> x, y, z = 1, 2, 3#不是元组 >>> type(x)<class 'int'>>>> h = x,y,z#是元组,所以元组的关键是“,”>>> h(1, 2, 3)
元组没有元组推导式,
tuple1 = (x**2 for x in range(10))”不会报错,因为得到了一个生成器<class 'generator'>,有next()方法,python3推荐__next__()写法
0 0
- Python---tuple
- python tuple
- Python:tuple
- python--tuple
- Python tuple
- python tuple
- Python-tuple
- Python的tuple
- Python中的tuple
- Python 之 tuple
- Python list and tuple
- Python Tuple 详解
- 【python】-list,tuple,dict
- <python>string,list,tuple
- python tuple函数使用
- python immutable tuple list
- Python:list,tuple,dict
- [Python]list, tuple,dict
- 服务器上Oracle System如何修改system用户密码
- 微信小程序开发—(八)canvas绘制图形
- OCX和DLL的区别
- 【CodeForces 792A】New Bus Route
- tomcat 的目录结构,servlet的配置与写法
- Python:tuple
- Oculus开发相关问题总结(一)Oculus登陆问题 Internal Error:OVR53225466
- javaweb:判断当前请求是否为移动设备访问
- Java多线程系列--“基础篇”01之 基本概念
- androidStudio快速打开工程
- word 2013中如何设置第几页共几页这种页码格式
- HttpServletRequestWrapper 实现xss注入(2)
- 剑指offer 37. 两个链表的第一个公共结点
- MFC笔记总结