while i < size: splited = wlist[i].strip().split('\t') 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\tno\teth0\n","pan0\t\tno\eth1\t\n","\t\t\eth2"]压缩为["eth0\tno\teth0\n","pan0\t\tno\eth1\t\\t\t\eth2"]
在pop的时候同时计算索引和长度。