赞
踩
list.clear()
->该函数无参数,无返回值In [49]: target =[1, 2, 3, 4, 5, 6]
In [50]: target.clear()
In [51]: print(target)
[]
clear
函数比直接定义一个空列表更节省性能# coding:utf-8
mixs = ['python', 1, (1,), {'name': 'insane'}]
print(mixs, len(mixs))
mixs.clear()
print(mixs, len(mixs))
['python', 1, (1,), {'name': 'insane'}] 4
[] 0
Process finished with exit code 0
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。