热线电话:13121318867

登录
2019-04-09 阅读量: 930
用%lprun进行逐行分析

用 %prun 对代码中的每个函数进行分析非常有用,但有时逐行代码分析报告更方便。该功能并没有内置于Python或IPython,但是可以通过安装line_profiler包来实现。首先利用Python的包管理工具 pip 安装 line_profiler 包:

pip install line_profiler

接下来可以用 IPython 导入 line_profiler 包提供的 IPython 扩展:

%load_ext line_profile

现在 %lprun 命令就可以对所有函数进行逐行分析了。

17.8156
0
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子