while i < size: splited = wlist[i].strip().split(' ') if len(splited) == 1: wlist[i - 1] = wlist[i - 1].strip() + wlist[i] wlist.pop(i) i = i-1 size = len(wlist) i = i + 1
["eth0 no eth0 ","pan0 noeth1 "," eth2"]压缩为["eth0 no eth0 ","pan0 noeth1 \t eth2"]
在pop的时候同时计算索引和长度。