Python中tuple与list的区别及tuple的使用
2018-01-11 21:33
441 查看
Python中的tuple内的元素是不可更改的,但是在tuple里可以嵌入list,tuple的list是可更改的。
#创建一个只有一个元素的tuple number_tuple = (1,) mixed_tuple = (1,2,["a","b"]) print(mixed_tuple) print(mixed_tuple[2][0]) #tuple不可改变,当tuple内有list的时候,可以改变list内的值 mixed_tuple[2].append("g") mixed_tuple[2][0] = "c" mixed_tuple[2][1] = "d" print(mixed_tuple) #一次赋多个值,一次也可以取出多个值 test_tuple = (1,2,3) (a,b,c) = test_tuple print(a,b,c)
相关文章推荐
- python里面的set、list、tuple区别和使用方法
- [Python] Tuple与List的区别
- Python中内置数据类型list,tuple,dict,set的区别和用法
- Python中内置数据类型list,tuple,dict,set的区别和用法
- Python学习笔记—使用list和tuple
- Python学习(二)---使用list和tuple
- python学习----list和tuple的区别
- Python入门之list,tuple,dict,set的区别
- Python3学习笔记-使用list和tuple
- Python list、tuple、dict区别
- Python中内置数据类型list,tuple,dict,set的区别和用法
- python中Dictionary、list、tuple的区别和联系
- python学习笔记使用list和tuple
- python基础——使用list和tuple
- Python中list、tuple、dict区别
- Python中list、tuple、dict区别
- Python中内置数据类型list,tuple,dict,set的区别和用法
- python re.findall()使用2个模型查找返回包含tuple的list
- python学习——使用list和tuple
- Python中list、tuple、dict区别