Python 也提供了重新加载已加载模块的基本支持
2017-11-11 12:12
381 查看
Python 也提供了重新加载已加载模块的基本支持.
[Example 1-8 #eg-1-8 会加载 3 次 hello.py 文件.
1.2.2.5. Example 1-8. 使用 reload 函数
File: builtin-reload-example-1.py
import hello
reload(hello)
reload(hello)
hello again, and welcome to the show
hello again, and welcome to the show
hello again, and welcome to the show
reload 直接接受模块作为参数.
注意:当你重加载模块时, 它会被重新编译, 新的模块会代替模块字典里的老模
块. 但是, 已经用原模块里的类建立的实例仍然使用的是老模块(不会被更新).
同样地, 使用 from-import 直接创建的到模块内容的引用也是不会被更新的.
[Example 1-8 #eg-1-8 会加载 3 次 hello.py 文件.
1.2.2.5. Example 1-8. 使用 reload 函数
File: builtin-reload-example-1.py
import hello
reload(hello)
reload(hello)
hello again, and welcome to the show
hello again, and welcome to the show
hello again, and welcome to the show
reload 直接接受模块作为参数.
注意:当你重加载模块时, 它会被重新编译, 新的模块会代替模块字典里的老模
块. 但是, 已经用原模块里的类建立的实例仍然使用的是老模块(不会被更新).
同样地, 使用 from-import 直接创建的到模块内容的引用也是不会被更新的.
相关文章推荐
- Python重新加载模块的实现方法
- python的学习:导入模块路径、重新加载路径、 is ==、深拷贝和浅拷贝
- python的学习:导入模块路径、重新加载路径、 is ==、深拷贝和浅拷贝
- MicroPython 1.8.6重新支持512K的模块
- python重新加载模块的方法有哪些
- Python 3.X重新加载模块
- Python 重新加载模块
- python中计时工具timeit模块的基本用法
- python datetime模块基本用法
- Python使用SocketServer模块编写基本服务器程序的教程
- 支持seaJs和requireJs的前端模块开发方案(三):加载器全局配置alias.js
- 解决办法:mysql_connect()不支持请检查mysql模块是否正确加载
- Python图像处理库:PIL中Image,ImageDraw等基本模块介绍
- [转]python数据持久存储:pickle模块的基本使用
- python datetime模块基本操作
- 使用Python编写爬虫的基本模块及框架使用指南
- 11.python并发入门(part9 多进程模块multiprocessing基本用法)
- Linux-Ubuntu16.04重新编译vim8.0支持Lua,Python3和YouCompleteMe
- python的scikit-learn的主要模块和基本使用
- python动态加载模块及变量是否存在方法