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...  # 修改后的内容



上一篇: Python 中将字符串转换为 DateTime 对象
下一篇:python库fire使用简介

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