Python 之 tuple
来源:互联网 发布:有mac版本的网游 编辑:程序博客网 时间:2024/05/25 05:36
Tuple is an immutable list.
- Tuples are faster than lists. If you're defining a constant set of values and all you're ever going to do with it is iterate through it, use a tuple instead of a list.
- It makes your code safer if you "write−protect" data that does not need to be changed. Using a tuple instead of a list is like having an implied assert statement that shows this data is constant, and that special thought (and a specific function) is required to override that.
- Remember that I said that dictionary keys can be integers, strings, and "a few other types"? Tuples are one of those types. Tuples can be used as keys in a dictionary, but lists can't be used this way.Actually, it's more complicated than that. Dictionary keys must be immutable. Tuples themselves are immutable, but if you have a tuple of lists, that counts as mutable and isn't safe to use as a dictionary key. Only tuples of strings, numbers, or other dictionary−safe tuples can be used as dictionary keys.
- Tuples are used in string formatting.
- Python 之 tuple
- Python之Tuple
- Python之创建tuple
- Python数据类型 之 tuple
- Python之创建tuple
- Python之创建tuple
- Python内置数据类型之Tuple
- Python基础数据结构之tuple
- Python之“可变”的tuple
- 《Python 源码剖析》 之 tuple
- python之tuple与list
- python入门之二:tuple
- Python基础篇之tuple一.(创建tuple)
- Python基础篇之tuple二.(创建单元素tuple)
- Python基础篇之tuple三.(“可变”的tuple)
- Python数据结构之——tuple
- Python学习第二篇之tuple
- python学习之List和Tuple
- Qt 中打开玻璃化DWM效果
- 开发人员本身是90分的测试人员
- 寒假总结
- 安装Grub到U盘
- 小技术团队的成长
- Python 之 tuple
- 从一个普通程序员到技术牛人的成长史
- javamail操作一
- andriod 【翻译】Manifest.xml application元素
- python 中的正则表达式
- 使用Objective-C中foreach循环的一大注意事项
- 快速排序
- C++ static、const和static const 以及它们的初始化
- 在Eclipse下安装Aptana3