Clear variable in python

后端 未结 7 1385
猫巷女王i
猫巷女王i 2020-12-22 17:16

Is there a way to clear the value of a variable in python?

For example if I was implementing a binary tree:

Class Node:
    self.left = somenode1
            


        
7条回答
  •  礼貌的吻别
    2020-12-22 18:06

    Actually, that does not delete the variable/property. All it will do is set its value to None, therefore the variable will still take up space in memory. If you want to completely wipe all existence of the variable from memory, you can just type:

    del self.left
    

提交回复
热议问题