seq = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
start = [2,9,18]
end = [6,12,20]
#output = seq[end[k]:start[k+1]]
我正在尝试结束[k]和开始[k 1] #seq [end [k]:start [k 1]]之间的序列
所以在这种情况下应该有2个序列.
outp1 = seq[6:9] #'GHI'
out2 = seq[12:18] #'MNOPQR'
解决方法:
for i in range(len(end)-1):
seq[end[i]:start[i+1]]
answer:-
'GHI'
'MNOPQR'