此代码:
def reformat_author(self):
rv = a = self.author
i0 = a.find(',')
# One and only one comma:
if i0 >= 0 and i0 == a.rfind(','):
t0 = a[0:i0]
t1 = a[i0+1, len(a)]
rv = '%s %s' % (t1, t0)
return rv.strip()
工作正常,将“史密斯,约翰”更改为“约翰·史密斯”。
但是当我改变t1 = a [i0 + 1,len(a)]至t1 = a [i0 + 1]
它没有,尽管doco说:
[从i到j的s切片被定义为索引为k的项序列,使得
i <= k 。 ...如果省略j或无,则使用len。 我误会了吗?
愚蠢的问题,请参阅我的评论。