Python之List和Tuple类型(入门3)
2017-02-16 21:35
357 查看
Python之List和Tuple类型
1. Python创建list
L = ['Adam', 95.5, 'Lisa', 85, 'Bart', 59] print L
2. Python按照索引访问list
L = [95.5,85,59] print L[0] print L[1] print L[2] print L[3]
3. Python之倒序访问list
L = [95.5, 85, 59] print L[-1] print L[-2] print L[-3] print L[-4]
4. Python之添加新元素
L = ['Adam', 'Lisa', 'Bart'] L.insert(2, 'Paul') print L
5. Python从list删除元素
L = ['Adam', 'Lisa', 'Paul', 'Bart'] L.pop(3) L.pop(2) print L
6. Python中替换元素
L = ['Adam', 'Lisa', 'Bart'] L[0] = 'Bart' L[-1] = 'Adam' print L
7. Python之创建tuple
t = (0,1, 2, 3, 4, 5, 6, 7, 8, 9) print t
8. Python之创建单元素tuple
t = ('Adam',) print t
9. Python之“可变”的tuple
t = ('a', 'b', ('A', 'B')) print t
相关文章推荐
- Python入门(二):List和Tuple类型
- 廖雪峰老师——Python入门( List和Tuple类型 )
- Python基础入门之List和Tuple类型三
- Python基础入门之List和Tuple类型一
- Python基础入门之List和Tuple类型二
- Python3学习(一)-基础、数据类型、变量、字符串和编码、list&tuple、if、for、while、dict、set、函数与参数
- Python学习入门基础教程(learning Python)--6 Python下的list数据类型
- Python中的list/tuple/dict/set数据类型详解
- Python中内置数据类型list,tuple,dict,set的区别和用法
- Python中内置数据类型list,tuple,dict,set的区别和用法
- Python——2list和tuple类型
- Python的数据类型:list和tuple
- Python数据类型list(列表)和tuple(元组)
- python中 List和Tuple类型
- Python基础-List和 Tuple 类型
- Python数据结构(二)序列类型list,tuple
- python入门--列表list和元祖tuple
- python 序列类型以及list(列表) 和 tuple(元组)详解 以及range的用法
- python--list和tuple类型--2
- python 科普:数据类型list、tuple、dict