擅长:python、mysql、java
<p>啊哈,我花了很长时间想在我需要的时候弄清楚。很高兴你不用经历。你知道吗</p>
<pre><code>def list_del(inp,poss):
'''delete items at indexes given in the list poss from list inp'''
try:
assert(isinstance(inp,list))
except AssertionError:
raise(AssertionError('input has to be a list, if numpy, using np.delete'))
inpu = inp
pos = 0
for i in list(sorted(poss)):
del inpu[i-pos]
pos += 1
return inpu
</code></pre>
<p>示例:</p>
<pre><code>list_del([0,1,2,3,4],[0,2,-1])
</code></pre>
<p>退货</p>
<pre><code>[1, 2]
</code></pre>
<p>就你而言:</p>
<pre><code>for i in list(x):
if i == 0:
deleting.append(i)
list_del(x,deleting)
list_del(y,deleting)
</code></pre>