Python3 List clear()方法

Python 3 教程 · 2019-02-06 14:29:21

描述

clear() 函数用于清空列表,类似于 del a[:]

语法

clear()方法语法:

list.clear()

参数

  • 无。

返回值

该方法没有返回值。

实例

以下实例展示了 clear()函数的使用方法:

#!/usr/bin/python3

list1 = ['Google', 'Codercto', 'Taobao', 'Baidu']
list1.clear()
print ("列表清空后 : ", list1)

以上实例输出结果如下:

列表清空后 :  []

点击查看所有 Python 3 教程 文章: https://codercto.com/courses/l/10.html

查看所有标签

Ajax for Web Application Developers

Ajax for Web Application Developers

Kris Hadlock / Sams / 2006-10-30 / GBP 32.99

Book Description Reusable components and patterns for Ajax-driven applications Ajax is one of the latest and greatest ways to improve users’ online experience and create new and innovative web f......一起来看看 《Ajax for Web Application Developers》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

在线进制转换器
在线进制转换器

各进制数互转换器