python学习列表(Lists).基础二
2024-09-01 03:30:45
列表(Lists)
序列是Python中最基本的数据结构,序列中的每个元素都分配一个数字,它的第一个索引是0第二个索引是1,依次类推。
列表是最常用的Python数据类型,它可以作为一个方括号内的逗号分隔值出现。
例子:
#coding=utf-8
#!/usr/bin/python
student=['uu','bb','qq','ww']
print (student[0])
print (student[1:3])
print (student[-1]) #访问最后一个元素
print (student[3])
student.append('xx') #末尾追加元素
print (student)
student.insert(1,'nn') #置顶位置添加元素
print (student)
student[0]='LL' #修改元素
print (student)
student.pop() #末尾删除元素
print (student)
student.pop(0) #删除指定位置的元素
print (student)
最新文章
- codevs2178 表达式运算Cuties[笛卡尔树]
- JavaScript 装逼指南
- LR工具使用之场景设置
- NC WebService接口开发流程
- 推荐一款系统软件:Unity tweak tool
- jQuery deferred when用法
- hdu 4856 Tunnels (bfs + 状压dp)
- oracle 过程函数,包的区别和联系
- nodemon 或者 Supervisor 监控 Express4.x的代码改动
- MySQL实用基础笔记
- 使用jQuery的hover事件在IE中不停闪动的解决方法
- Python之编写登陆接口
- linux 下启动java jar包 shell
- Python(字符编码)
- js 奇偶判断
- 用Java实现MVPtree——MVPtree点集内去重以及衍生出来的多维向量Hash问题
- jquery鼠标放上去显示悬浮层即弹出定位的div层
- 【ibatis】IBatis的SQL批量操作
- 【WPF】右键菜单ContextMenu可点击区域太小的问题
- easyui treegrid idField 所在属性中值有花括号(如Guid)当有鼠标事件时会报错,行记录一下