One - One Code All

Blog Content

python重新加载模块reload

Python   2017-06-17 18:36:22


reload() 是 Python 提供的一种简洁的方式,在不同的 Python 版本中有不同的表现形式:


在 Python 2.x 中,reload() 是内置函数。

在 Python 3.0 - 3.3 中,可以使用 imp.reload(module)。

在 Python 3.4 中,imp 已经被废弃,取而代之的是 importlib。

>>> import importlib

>>> import hello

Hello, Python!  # 修改前的内容

>>> 

>>> importlib.reload(hello)

I am coming...  # 修改后的内容



上一篇:springboot项目jar包如何引入外置配置文件
下一篇:【转载】智能投顾与智能投研:华尔街之狼来了

The minute you think of giving up, think of the reason why you held on so long.