When is del useful in python?
问题 I can't really think of any reason why python needs the del keyword (and most languages seem to not have a similar keyword). For instance, rather than deleting a variable, one could just assign None to it. And when deleting from a dictionary, a del method could be added. Is there any reason to keep del in python, or is it a vestige of Python's pre-garbage collection days? 回答1: Firstly, you can del other things besides local variables del list_item[4] del dictionary["alpha"] Both of which