擅长:python、mysql、java
<p>请参阅本<a href="https://stackoverflow.com/questions/57400399/implementation-of-linkedlist-in-python-getitem-function">post</a>中的delete函数</p>
<pre class="lang-py prettyprint-override"><code>class LinkedList(Node):
...
def delete(self,value):
temp = self.__head
while temp!=None:
if temp.value == value and temp == self.__head:
self.__head = temp.ref
del temp
self.__count -= 1
break
elif temp.ref != None and temp.ref.value == value:
temp_ref = temp.ref.ref
del temp.ref
self.__count -= 1
temp.ref = temp_ref
break
temp = temp.ref
</code></pre>