python tuple
来源:互联网 发布:淘宝如何认证大v 编辑:程序博客网 时间:2024/06/06 10:45
python的list格式是 t=[1,2],可以随时添加或删除里面元素
python的tuple格式是t=(1,2),一旦定义就不可以修改
以下转载自Eric2016_Lv
# -*- coding: utf-8 -*-"""Python Version: 3.5Created on Mon May 8 17:04:45 2017E-mail: Eric2014_lv@sjtu.edu.cn@author: DidiLv"""d = {(x, x + 1): x for x in range(10)} # Create a dictionary with tuple keysprint(d)t = (5, 6) # Create a tupleprint(type(t)) # Prints "<type 'tuple'>"print(d[t]) # Prints "5"print(d[(1, 2)]) # Prints "1"# 这只是一个结合的dictionary的表示,没啥难的# 元组不是一个可以迭代的,更改的容器# 输出为:#{(0, 1): 0, (1, 2): 1, (5, 6): 5, (2, 3): 2, (4, 5): 4, (6, 7): 6, (8, 9): 8, (9, 10): 9, (3, 4): 3, (7, 8): 7}#<class 'tuple'>#5#1
阅读全文
0 0
- Python---tuple
- python tuple
- Python:tuple
- python--tuple
- Python tuple
- python tuple
- Python-tuple
- Python的tuple
- Python中的tuple
- Python 之 tuple
- Python list and tuple
- Python Tuple 详解
- 【python】-list,tuple,dict
- <python>string,list,tuple
- python tuple函数使用
- python immutable tuple list
- Python:list,tuple,dict
- [Python]list, tuple,dict
- Java调用weka代码
- Python3学习(16)--匿名函数lambda
- 复选框选取表格一行的值
- js中的延迟执行和定时执行
- Python基本知识
- python tuple
- PHP中this语句的用法
- CSS中position属性 (absolute,relative,static,fixed)
- 利用JS脚本通过getAttribute()和setAttribute()等对CSS样式进行操作
- Android组件RecyclerView添加分割线
- 利用HTML5的canvas制作万花筒动画特效
- JS中数组对象去重
- jQuery对象与JS原生dom对象之间的转换
- 总结json