%reload_ext autoreload %autoreload 2
以上代码只需执行一次。
对已import的方法做修改,修改的内容直接生效,不需要重新import。
新增的方法需要import才能使用,import之后之前定义的类对象可以使用这个新方法。
在一个module中删除一个方法,即使重新import这个module,那个已删除的方法仍然可用。
Usage¶
The following magic commands are provided:
%autoreload
, %autoreload now
Reload all modules (except those excluded by
%aimport
) automatically now.
%autoreload 0
, %autoreload off
Disable automatic reloading.
%autoreload 1
, %autoreload explicit
Reload all modules imported with
%aimport
every time before executing the Python code typed.
%autoreload 2
, %autoreload all
Reload all modules (except those excluded by
%aimport
) every time before executing the Python code typed.
%autoreload 3
, %autoreload complete
Same as 2/all, but also adds any new objects in the module. See unit test at IPython/extensions/tests/test_autoreload.py::test_autoload_newly_added_objects
Adding
-p
to the%autoreload
line will print autoreload activity to standard out.--log
or-l
will do it to the log at INFO level; both can be used simultaneously.
%aimport
List modules which are to be automatically imported or not to be imported.
%aimport foo
Import module ‘foo’ and mark it to be autoreloaded for
%autoreload 1
%aimport foo, bar
Import modules ‘foo’, ‘bar’ and mark them to be autoreloaded for
%autoreload 1
%aimport -foo
Mark module ‘foo’ to not be autoreloaded.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
2023-09-29 Go - Using Log Levels
2023-09-29 Go - Logging to File
2023-09-29 Go - Inspecting Errors
2023-09-29 Go - Wrapping an Error with Other Errors
2023-09-29 Go - Creating Customized Errors
2023-09-29 Go - Using Multiple Versions of the Same Dependent Packages
2023-09-29 Go - Requiring Local Versions of Dependent Packages