用del操作即可:
import math
print(math.pi)
del math
print(math.pi)
输出:
3.141592653589793
Traceback (most recent call last):
File "test.py", line xx, in <module>
print(math.pi)
NameError: name 'math' is not defined
用del操作即可:
import math
print(math.pi)
del math
print(math.pi)
输出:
3.141592653589793
Traceback (most recent call last):
File "test.py", line xx, in <module>
print(math.pi)
NameError: name 'math' is not defined