Python3.4 for循环迭代问题

Python3.4 for循环迭代问题,python,for-loop,python-3.x,Python,For Loop,Python 3.x,我一直在做一个项目,在这个项目中,我遍历一个数据列表,删除某些字符之前的所有文本。(这里有一个例子供参考) >>myList=['foo设置myList[elementIndex]= ['oo<foo', 'bar<bar', 'baz<baz'] myList[elementIndex] = element[charIndex + 1:] # removes f element[charIndex + 1:] is from the `first index + 1`

我一直在做一个项目,在这个项目中,我遍历一个数据列表,删除某些字符之前的所有文本。(这里有一个例子供参考)


>>myList=['foo设置
myList[elementIndex]=

['oo<foo', 'bar<bar', 'baz<baz']

myList[elementIndex] = element[charIndex + 1:] # removes f

element[charIndex + 1:]  is from the `first index + 1` so it becomes `'oo<foo'`
哪些产出:

['<foo', '<bar', '<baz']
['
 myList[elementIndex] = element[charIndex + 1 :]
 element = element[charIndex + 1 :]
['<foo', '<bar', '<baz']
[s[s.index("<"):] if "<" in s else s for s in myList ]