码迷,mamicode.com
首页 > 其他好文 > 详细

Deleting elements

时间:2014-07-16 19:26:12      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   2014   re   c   

There are several ways to delete elements from a list. If you know the index of the element you want, you can use pop:

bubuko.com,布布扣                       

pop modifies the list and returns the element that was removed.

If you don’t need the removed value, you can use del operator:

bubuko.com,布布扣
If you know the element you want to remove (but not the index), you can use remove:

 bubuko.com,布布扣

The return value from remove is None.

To remove more than one element, you can use del with a slice index:

 bubuko.com,布布扣

As usual, the slice selects all elements up to, but not including, the second index.

 

 

from Thinking in Python

Deleting elements,布布扣,bubuko.com

Deleting elements

标签:style   blog   http   2014   re   c   

原文地址:http://www.cnblogs.com/ryansunyu/p/3841298.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!