马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
>>> s = [1, 2, 3, 4, 5]
>>> # 下面的做法等同于 s.append(6)
>>> s[len(s):] = [6]
>>> s
[1, 2, 3, 4, 5, 6]
>>> s[len(s):] = [7, 8, 9]
>>> s
[1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> a = [1, 3, 4, 5]
>>> a.insert(1, 2)
>>> a
[1, 2, 3, 4, 5]
>>> heros = ["金刚", "灭霸", "雷神"]
>>> heros.remove("灭霸")
>>> heros
['金刚', '雷神']
>>> # 列表中存在多个匹配的元素,那么它只会删除第一个
>>> heros
['金刚', '雷神']
>>> heros.pop(1)
'雷神'
>>> heros
['金刚']
>>> heros.clear()
>>> heros
[] |