from _ _future_ _ import generators
def paragraphs(fileobj, separator='\n'):
if separator[-1:] != '\n': separator += '\n'paragraph = []
for line in fileobj:
if line == separator:
if paragraph:yield ''.join(paragraph)
paragraph = []
else:paragraph.append(line)
if paragraph: yield ''.join(paragraph)
做如下的操作:>>>
a=range(6)
>>>
a
[0,
1,
2,
3,
4,
5]
>>>
a[0:3],a[5]=[[2,3,4,5],7]
>>>
a
[2,
3,
4,
5,
3,
7,
5]
Python应该是不支持非等差数列的index
slice,
你需要自己把你的下标分割为几个等差数列,然后做slice操作。