Python 进阶 —— 重访 tuple
2016-06-02 09:33
501 查看
1. 单元素?(3) ⇒ (3, )
>> l = [3] >> type(l) list >> t = (3) >> type(t) int >> l = [[3]] >> l [[3]] >> t = ((3, 4)) >> t (3, 4)
tuple 对单元素的处理识别为:
>> t = (3, ) >> t = ((3, ), )
2. tuple 可变乎?
+及
+=的运算符重载
>> t = (1, 2) >> t + (3, 4) (1, 2, 3, 4) >> t += (3, 4) >> t (1, 2, 3, 4)
3. tuple 可变乎?(二)
>> t = ([1, 2], 3, 4) >> t[0][1] = 20 >> t ([1, 20], 3, 4)
4. 位置参数(positional parameters)与 tuple
Python 解释器将位置参数解析为 tuple,哪怕只有一个参数。>> def foo(*args): >> print(args) >> foo(1) (1,)
相关文章推荐
- leetcode 48. Rotate Image-矩阵旋转
- Python复杂对象转JSON
- 17个新手常见Python运行时错误
- python random模块
- 2. python入门杂记
- python类1
- [python]源码:对象
- Python Version 2.7 required which was not found in the registry
- [python]编码处理小结
- 怎么查看python是32位还是64位的
- 解决python连接mysql,UTF-8乱码问题
- 为什么会出现Python Exception <class 'gdb.MemoryError'> Cannot access memory at address 问题?
- 文成小盆友python-num4 装饰器,内置函数
- Python-Matplotlib安装及简单使用
- Python:Django【基础篇】
- 初识python 交叉排序
- 2016年6月2日 几乎是强迫自己在更新 关于python的多线程处理
- [Python爬虫]爬取贴吧图片
- leetcode(12),Ugly Number(python)
- Python实现优先级队列结构的方法详解