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相关推荐

  1. Python中list,tuple,dict,set的区别和用法

    Python语言简洁明了,可以用较少的代码实现同样的功能.这其中Python的四个内置数据类型功不可没,他们即是list, tuple, dict, set.这里对他们进行一个简明的总结. List ...

  2. [转载] python中元组(tuple)用法总结

    参考链接: Python | tuple函数 一.tuple也是一个class,是不可变的list类型,不可以增删改. 创建: tup1 = ('physics', 'chemistry', 1997 ...

  3. python中元组(tuple)用法总结

    一.tuple也是一个class,是不可变的list类型,不可以增删改. 创建: tup1 = ('physics', 'chemistry', 1997, 2000); tup2 = (1, 2, ...

  4. tuple在python中什么意思_在Python中,*tuple和**dict是什么意思?

    在函数调用中 *t表示"将此元组的元素作为此函数调用的位置参数."def foo(x, y): print(x, y) >>> t = (1, 2) >&g ...

  5. python中元组tuple官方使用手册

    https://docs.python.org/3/tutorial/datastructures.html#tuples-and-sequences

  6. python中的tuple_python 数据类型 - tuple

    tuple 元组 今天跟大家分享一下Python里面tuple数据类型的学习 ps:list数据类型,之前是写在了jianshu上,暂时我也还没有搬过来,所以贴上链接吧 概念 tuple,即元组.是P ...

  7. Python中的星号本质及其使用方法详解

    翻译:Python 开发者 - 一汀, 英文:Trey Hunner http://blog.jobbole.com/114655/ Python开发者 在 Python 中有很多地方可以看到*和** ...

  8. python中一共有多少个关键字-Python 为什么会有命名关键字参数?

    题主会有这样的疑问是因为对Python函数的参数还了解不多.位置参数也不一定是必传的,事实上在下面你会看到参数是否必传(也就是有无默认值)与它是位置的还是关键字的根本无关.下文黄底图片的例子能充分为你 ...

  9. python中序列(列表list和元组tuple)的用法

    数据结构是以某种方式(如通过编号)组合起来的数据元素的集合.再python中最基本的数据结构为序列(sequence).序列中的元素是有序的,索引从0开始,用负索引表示序列末尾元素的位置. pytho ...

最新文章

  1. 服务被干爆了!竟然是日志的锅!!
  2. java标志清理_JVM内存管理之GC算法精解(五分钟让你彻底明白标记/清除算法)...
  3. css怎么给字体夹阴影,css怎么给字体加阴影效果
  4. C语言试题二十三之编写一个函数void function(int tt[m][n],int pp[n]),tt指向一个m行n列的二维函数组,求出二维函数组每列中最小元素,并依次放入pp所指定一维数组中
  5. 第一阶段 XHTML.定位样式
  6. Python中的xxx+=xxx和xxx=xxx+xxx一些区别及执行过程
  7. pppoe拨号的外网ip无法ping通_【思唯网络学院】 五大网络概念:IP地址、子网掩码、网关、DHCP服务和PPPoE拨号...
  8. WinEdt中xelatex.exe等exe did not succeed问题
  9. 警告: git command could not be found. Please create an alias or add it to your PATH
  10. 计算机硬盘应该什么格式化,硬盘应该格式化成哪种格式为好?
  11. [计算机数值分析]牛顿插值公式
  12. Arduino 利用ADS1115 AD转换模块进行数据读取
  13. 金戈铁马 Android NDK 实战篇:男人之间的那些事
  14. 计算机无法自动排列,如何设置Excel表不能自动排序
  15. Android 开发即时聊天工具 YQ :(五) 发送消息
  16. Unity学习 渲染管线介绍
  17. 基于51单片机的电子钟设计[本科自动化毕业设计论文,源码,实物]
  18. Bitmiracle Docotic.Pdf Library 8.8.14015 Crack
  19. 数学建模多元线性回归内生性问题的蒙特卡洛模拟matlab代码
  20. app毕业设计开题报告基于Uniapp+SSM实现的安卓的掌上校园系统[包运行成功]计算机毕业论文

热门文章

  1. 【python--爬虫】彼岸图网高清壁纸
  2. 1423. 可获得的最大点数 maxScore
  3. 华为防火墙-1-安全区域
  4. 考研公共课总结与建议(持续更新)
  5. KILLZONE 2 显示技术详解
  6. 琅软搜域名:中国搜.搜(CNS.so)
  7. <架构师必修课>-nginx
  8. 运用STM32对SD卡数据读取
  9. 欧盟首个数据保护条例GDPR生效,你可能需要这份中文版的全文(丁晓东译) |下...
  10. 编程好学吗?零基础能学编程吗?