print difflist
for line in difflist:
if ((line.startswith('<'))or (line.startswith('>')) or (line.startswith('---'))):
difflist.remove(line)
print difflist
在这里,最初,
difflist = ['1a2', '> ', '3c4,5', '< staring', '---', '> starring', '> ', '5c7', '< at ', '---', '> add ', '']
我对代码的期望是打印
['1a2', '3c4,5', '5c7', '']
但我得到的是
difflist= ['1a2', '3c4,5', '---', '> ', '5c7', '---', '']