-1 没有在数组的最后一个索引处插入“hello”
如果我有一个数组,x:
>>> x = [1, 2, 3] then
>>> x.insert(-1, "hello")
>>> print(x)
[1, 2, 'hello', 3]
为什么 -1 不在数组的最后一个索引处插入“hello”?由于 -1 索引指的是列表的最后一项,所以我期待:
[1, 2, 3, “你好”]
GCT1015
相关分类