python移除加载的模块(import 逆操作)

del <模块名> 就能移除模块,清除环境

   []: import numpy as np
   []: np.pi
   []: Out[41]: 3.141592653589793
   []: del np
   []: np.pi
     Traceback (most recent call last):
      File "D:\ROOT\AppliedWare\python3\lib\site-packages\IPython\core\interactiveshell.py", line 3291, in run_code
        exec(code_obj, self.user_global_ns, self.user_ns)
      File "", line 1, in 
        np.pi
    NameError: name 'np' is not defined

你可能感兴趣的:(others)