学习Python列表的访问,添加和删除
来源:互联网 发布:java encoder编码器 编辑:程序博客网 时间:2024/06/05 22:39
motorcycles = ['honda','yamaha','suzuki']print(motorcycles)motorcycles[0] = 'ducati'print(motorcycles)motorcycles = ['honda','yamaha','suzuki']print(motorcycles)motorcycles.append('ducati')print(motorcycles)motorcycles = []motorcycles.append('honda')motorcycles.append('yamaha')motorcycles.append('suzuki')print(motorcycles)motorcycles = ['honda','yamaha','suzuki']motorcycles.insert(0,'ducati')print(motorcycles)motorcycles = ['honda','yamaha','suzuki']print(motorcycles)del motorcycles[0]print(motorcycles)motorcycles = ['honda','yamaha','suzuki']print(motorcycles)del motorcycles[1]print(motorcycles)motorcycles = ['honda','yamaha','suzuki']print(motorcycles)popped_motorcycles = motorcycles.pop()print(motorcycles)print(popped_motorcycles)motorcycles = ['honda','yamaha','suzuki']last_owned = motorcycles.pop()print("The last motorcycles I owned was a " + last_owned.title() + ".")motorcycles = ['handa','yamaha','suzuki']first_owned = motorcycles.pop(0)print('The first motorcycle I owned was a ' + first_owned.title() +'.')motorcycles = ['honda','yamaha','suzuki','ducati']print(motorcycles)motorcycles.remove('ducati')print(motorcycles)motorcycles = ['handa','yamaha','suzuki','ducati']print(motorcycles)too_expensive = 'ducati'motorcycles.remove(too_expensive)print(motorcycles)print("\nA " + too_expensive.title() + " is too expensive for me.")
阅读全文
0 0
- 学习Python列表的访问,添加和删除
- Python学习记录02 列表添加和删除元素
- pyhton列表的添加删除和切片
- 【Python】给列表添加删除元素的方法
- 下拉列表的添加,删除
- 线性列表的添加、删除、插入和修改
- 笨方法学习Python-习题34: 访问列表的元素
- Python列表和字典的学习
- python 的列表遍历删除
- python 的列表遍历删除
- 【python】列表的删除操作
- python 的列表遍历删除
- python 的列表遍历删除
- Python脚本测试---列表的排序和删除
- Python 列表 list 数据类型创建list、添加元素和删除元素
- XMPP-好友列表模块的注册和好友列表获取,添加,删除
- 基于python的添加和删除安全组的脚本
- python的【列表list】:定义、索引、添加、删除、遍历、长度;组合、重复、反转、切片、比较;排序
- 【HDU1512】【左偏树】Monkey King 题解
- Unity3D UGUI学习小结
- Github收藏之Awesome C/C++
- JavaScript 30天每日效果图
- 智能建模之最小二乘辨识LS:Matlab实现
- 学习Python列表的访问,添加和删除
- 选择语句和循环语句练习
- DOM方法
- 十五天
- Android学习之简单使用SeekBar
- 关于MySQL 通用查询日志和慢查询日志分析
- 浅谈自己对构造函数、析构函数、复制构造函数的理解
- java判断字符串是否为空的方法
- [翻译自MOS文章]警告:在rhel7 or OL(RHCK)7上安装GI 12.2.0.1时 root.sh fails并有报错"CLSRSC-400"