Python 官方文档:入门教程 => 点击学习
reload函数是使用模块名称,而不是变量名称,也就是说当你把它改变了名称,它也是加载原来的名称。当使用reload时,这个模块会被重新编译,新的模块
当使用reload时,这个模块会被重新编译,新的模块替换原来的模块。如果之前从这个模块创建的实例仍然使用旧的模块实现。特别是使用from-import语句加载的名称,也不会被更新。
例如:
# File: builtin-reload-example-1.py
from imp import reload
import hello
reload(hello)
reload(hello)
=== RESTART: D:/work/csdn/python_Game1/example/builtin-reload-example-1.py ===
hello again, and welcome to the show
hello again, and welcome to the show
hello again, and welcome to the show
>>>
这里helo.py代码如下:
print('hello again, and welcome to the show')
--结束END--
本文标题: python里使用reload函数
本文链接: https://www.lsjlt.com/news/184156.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0