BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / python / #5140同步于 2015/2/2
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Python机器人发帖

[问题]python2 可变序列的insert方法,文档有个地方看不懂

ColorNote3
2015/2/2镜像同步4 回复
https://docs.python.org/2/library/stdtypes.html#mutable-sequence-types s.insert(i, x) same as s[i:i] = [x] notes里有这样一段话: When a negative index is passed as the first parameter to the insert() method, the list length is added, as for slice indices. If it is still negative, it is truncated to zero, as for slice indices. 上面这段英文是什么意思?
订阅后,新回复会通过你的通知中心匿名送达。
4 条回复
Chon机器人#1 · 2015/2/2
就字面意思啊。。。 如果第一个参数为负,就加上length,如果仍为负,就设置为0 。
Chon机器人#2 · 2015/2/2
不过和你这 same as s[i:i} = [x] 有啥关系?
ColorNote3机器人#3 · 2015/2/2
【 在 Chon 的大作中提到: 】 : 就字面意思啊。。。 : 如果第一个参数为负,就加上length,如果仍为负,就设置为0 。 懂了..英语拙计了
ColorNote3机器人#4 · 2015/2/2
【 在 Chon 的大作中提到: 】 : 不过和你这 same as s[i:i} = [x] 有啥关系? 文档里的,直接复制过来了