Python中的tuple
1.空的tuple: tup1 = ();
2.只含有一个元素的tuple:
tup1 = (50,); #注意,必须有,尽管只有一个元素 3Delete Tuple Elements:
Removing individual tuple elements is not possible. There is, of course, nothing wrong with putting together another tuple with the undesired elements discarded.
To explicitly remove an entire tuple, just use the del statement:
Example:
tup = ('physics', 'chemistry', 1997, 2000); print (tup); del tup; print ("After deleting tup : ") print (tup); |
This will produce following result. Note an exception raised, this is because after del tup tuple does not exist any more:
('physics', 'chemistry', 1997, 2000) After deleting tup : Traceback (most recent call last): File "test.py", line 9, in <module> print tup; NameError: name 'tup' is not defined
相关函数:
Python includes following tuple functions
SN | Function with Description |
---|---|
1 |
cmp(tuple1, tuple2) Compares elements of both tuples. |
2 |
len(tuple) Gives the total length of the tuple. |
3 |
max(tuple) Returns item from the tuple with max value. |
4 |
min(tuple) Returns item from the tuple with min value. |
5 |
tuple(seq) Converts a list into tuple. |
Python中的tuple相关推荐
- Python中list,tuple,dict,set的区别和用法
Python语言简洁明了,可以用较少的代码实现同样的功能.这其中Python的四个内置数据类型功不可没,他们即是list, tuple, dict, set.这里对他们进行一个简明的总结. List ...
- [转载] python中元组(tuple)用法总结
参考链接: Python | tuple函数 一.tuple也是一个class,是不可变的list类型,不可以增删改. 创建: tup1 = ('physics', 'chemistry', 1997 ...
- python中元组(tuple)用法总结
一.tuple也是一个class,是不可变的list类型,不可以增删改. 创建: tup1 = ('physics', 'chemistry', 1997, 2000); tup2 = (1, 2, ...
- tuple在python中什么意思_在Python中,*tuple和**dict是什么意思?
在函数调用中 *t表示"将此元组的元素作为此函数调用的位置参数."def foo(x, y): print(x, y) >>> t = (1, 2) >&g ...
- python中元组tuple官方使用手册
https://docs.python.org/3/tutorial/datastructures.html#tuples-and-sequences
- python中的tuple_python 数据类型 - tuple
tuple 元组 今天跟大家分享一下Python里面tuple数据类型的学习 ps:list数据类型,之前是写在了jianshu上,暂时我也还没有搬过来,所以贴上链接吧 概念 tuple,即元组.是P ...
- Python中的星号本质及其使用方法详解
翻译:Python 开发者 - 一汀, 英文:Trey Hunner http://blog.jobbole.com/114655/ Python开发者 在 Python 中有很多地方可以看到*和** ...
- python中一共有多少个关键字-Python 为什么会有命名关键字参数?
题主会有这样的疑问是因为对Python函数的参数还了解不多.位置参数也不一定是必传的,事实上在下面你会看到参数是否必传(也就是有无默认值)与它是位置的还是关键字的根本无关.下文黄底图片的例子能充分为你 ...
- python中序列(列表list和元组tuple)的用法
数据结构是以某种方式(如通过编号)组合起来的数据元素的集合.再python中最基本的数据结构为序列(sequence).序列中的元素是有序的,索引从0开始,用负索引表示序列末尾元素的位置. pytho ...
最新文章
- 服务被干爆了!竟然是日志的锅!!
- java标志清理_JVM内存管理之GC算法精解(五分钟让你彻底明白标记/清除算法)...
- css怎么给字体夹阴影,css怎么给字体加阴影效果
- C语言试题二十三之编写一个函数void function(int tt[m][n],int pp[n]),tt指向一个m行n列的二维函数组,求出二维函数组每列中最小元素,并依次放入pp所指定一维数组中
- 第一阶段 XHTML.定位样式
- Python中的xxx+=xxx和xxx=xxx+xxx一些区别及执行过程
- pppoe拨号的外网ip无法ping通_【思唯网络学院】 五大网络概念:IP地址、子网掩码、网关、DHCP服务和PPPoE拨号...
- WinEdt中xelatex.exe等exe did not succeed问题
- 警告: git command could not be found. Please create an alias or add it to your PATH
- 计算机硬盘应该什么格式化,硬盘应该格式化成哪种格式为好?
- [计算机数值分析]牛顿插值公式
- Arduino 利用ADS1115 AD转换模块进行数据读取
- 金戈铁马 Android NDK 实战篇:男人之间的那些事
- 计算机无法自动排列,如何设置Excel表不能自动排序
- Android 开发即时聊天工具 YQ :(五) 发送消息
- Unity学习 渲染管线介绍
- 基于51单片机的电子钟设计[本科自动化毕业设计论文,源码,实物]
- Bitmiracle Docotic.Pdf Library 8.8.14015 Crack
- 数学建模多元线性回归内生性问题的蒙特卡洛模拟matlab代码
- app毕业设计开题报告基于Uniapp+SSM实现的安卓的掌上校园系统[包运行成功]计算机毕业论文