Python中的tuple
来源:互联网 发布:数据库decode 编辑:程序博客网 时间:2024/05/21 17:02
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
Compares elements of both tuples.2len(tuple)
Gives the total length of the tuple.3max(tuple)
Returns item from the tuple with max value.4min(tuple)
Returns item from the tuple with min value.5tuple(seq)
Converts a list into tuple.
- Python中的tuple
- Python中的tuple
- Python中的tuple
- python中的list和tuple
- Python中的List和tuple
- python中的list和tuple
- python中的list和tuple
- Python中的List和Tuple
- Python中的List,Tuple和Dictionary
- python中的list,tuple 和 dictionary
- Python中的有序列表List&Tuple
- Python中的list、tuple、dict、set
- python中的list、tuple、dict辨析
- Python中的list/tuple/dict/set详解
- Python---tuple
- python tuple
- Python:tuple
- python--tuple
- 简单的分页代码!!
- jxl 从excel导入数据到数据库中;java中jdbc连接数据库
- Android SDK2.3 更新指南
- 实现FreeModbus协议所需要的软/硬件需求
- 无法解析的外部符号的 3 种可能
- Python中的tuple
- 界面设计原则
- android中ImageView制作台标
- Windows Phone 7 开发 31 日谈——第25日:外部API
- 高手教教
- 并行计算
- 模块-modbus模块
- javaScript问题
- 字符设备驱动程序(理论篇)