博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
del Statement
阅读量:4031 次
发布时间:2019-05-24

本文共 719 字,大约阅读时间需要 2 分钟。

5.2 The del statement

There is a way to remove an item from a list given its index instead of its value: the del statement. This differs from the pop() method which returns a value. The del statement can also be used to remove slices from a list or clear the entire list (which we did earlier by assignment of an empty list to the slice). For example:

>>> 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    []

del can also be used to delete entire variables:

>>> del a

Referencing the name a hereafter is an error (at least until another value is assigned to it). We'll find other uses for del later

转载地址:http://qlhbi.baihongyu.com/

你可能感兴趣的文章
fastcgi_param 详解
查看>>
Nginx配置文件(nginx.conf)配置详解
查看>>
标记一下
查看>>
一个ahk小函数, 实现版本号的比较
查看>>
IP报文格式学习笔记
查看>>
autohotkey快捷键显示隐藏文件和文件扩展名
查看>>
Linux中的进程
查看>>
学习python(1)——环境与常识
查看>>
学习设计模式(3)——单例模式和类的成员函数中的静态变量的作用域
查看>>
自然计算时间复杂度杂谈
查看>>
当前主要目标和工作
查看>>
POJ 2363 Blocks(我的水题之路——立方体体积和表面积,暴力)
查看>>
POJ 2390 Bank Interest(我的水题之路——double和floa计算差别)
查看>>
POJ 2459 Feed Accounting(我的水题之路——英文题啊!!!)
查看>>
POJ 2470 Ambiguous permutation(我的水题之路——位置和值的队列)
查看>>
POJ 2498 StuPId(我的水题之路——from back to front- -!)
查看>>
POJ 2535 Very Simple Problem(我的水题之路——看错题)
查看>>
POJ 2538 WERTYU(我的水题之路——键盘错位)
查看>>
POJ 2551 Ones(我的水题之路——重点,末尾有几个1)
查看>>
POJ 2562 Primary Arithmetic(我的水题之路——模拟加法进位)
查看>>