在最新版本的 MATLAB 中,可以使用 Ctrl-Enter 执行以 %%
开头的两行之间的代码区域。这样的区域称为 code cell ,并且它允许快速的代码测试和调试。
例如
%% This is the beginning of the 1st cell
a = 5;
%% This is the end of the 1st cell and beginning of the 2nd cell
% This is just a comment
b = 6;
%% This is the end of the 2nd cell
是否有任何支持类似功能的 python 编辑器?
编辑:我刚刚发现 Spyderlib支持使用 F9 的“ block ”执行(代码区域用空行分隔),但作为 this thread提到,这个功能仍然不是很健壮(特别是与循环结合使用)。
最佳答案
Python 的交互式编辑器 IEP有一个 Matlab 样式的单元格符号来标记代码段(通过以 '##' 开始一行),默认的快捷方式也是 Ctrl+Enter :
## Cell one
"""
A cell is everything between two commands starting with '##'
"""
a = 3
b = 4
print('The answer is ' + str(a+b))
## Cell two
print('Hello World')
关于python - Python 编辑器中的单元格模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6719972/