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