del语句
2015-08-29 06:58
232 查看
5.2. del 语句
有个方法可以从列表中按给定的索引而不是值来删除一个子项: del 语句。它不同于有返回值的 pop() 方法。语句 del 还可以从列表中删除切片或清空整个列表(我们以前介绍过一个方法是将空列表赋值给列表的切片)。例如:>>> a = [-1, 1, 66.25, 333, 333, 1234.5] >>> del a[0] >>> a [1, 66.25, 333, 333, 1234.5] >>> del a[2:4] >>> a [1, 66.25, 1234.5] >>> del a[:] >>> a []
相关文章推荐
- OSChina 周六乱弹 —— 鬼节最怕碰见什么鬼?
- django 1.8 官方文档翻译: 3-1-1 URL调度器
- [CareerCup] 7.3 Line Intersection 直线相交
- 【LeetCode-面试算法经典-Java实现】【225-Implement Stack using Queues(用队列实现栈操作)】
- 【LeetCode-面试算法经典-Java实现】【223-Rectangle Area(矩形区域)】
- Some projects cannot be imported because they already exist in the workspace
- 【LeetCode-面试算法经典-Java实现】【219-Contains Duplicate II(包含重复元素II)】
- C语言的字符处理函数库
- USACO 1.1 Milking Cows
- Power of Two
- Delete Node in a Linked List
- 小米雷军:疑似偷学华为,400亿美金背后的人才密码
- LeetCode Add Two Numbers
- LeetCode Add Two Numbers
- 再论WaaS与LaaS并举,增强国人底气和自信
- 留学创业磨难多——展讯武平
- 哈哈哈
- 黑马程序员——Java基础---IO(二)
- Servlets - Examples
- Servlets - Life Cycle