方法:直接赋值为空list
对于一个一维list:
>>> a = [1,2,3] >>> a = [] >>> a []
对于一个二维list:
>>> a = [[1,2,3,4,5],[6,7,8,9,10]] >>> a = [[],[]] >>> a [[], []]
想清空二维list中的某一维;
>>> a = [[1,2,3,4,5],[6,7,8,9,10]] >>> a[0] = [] >>> a [[], [6, 7, 8, 9, 10]]
时间: 2024-10-25 07:37:57