List, Dictionary, Set 常用的函数
List
list.remove(value)
, remove the first one equals to the value in listlist[index] = list.pop(index)
, can return or not return, remove by indexlist.append(value)
, add the value at the end of this listlist.append(sublist[:])
, add sublist to the nested listlist.extend(list2)
, flat add list2 to the end of the list
Dictionary
for key in dic
for key, value in dic.items()
Set
set.add(value) 如果要添加的数已存在则无任何操作
set.remove(value) 如果要移除的数不存在则报错
set.discard(value) 如果要移除的数不存在则无任何操作
Last updated
Was this helpful?