python - Python 编辑器中的单元格模式

标签 python matlab ide

在最新版本的 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/

相关文章:

python - 使用 OpenCV 在给定时间从视频中提取图像

c - Gcc 编译器命令和选项

python - MacOS 上的 pyqt5 默认 native 菜单文本

Matlab specgram 过时 vs spectrogram 替换

matlab - 如何执行优化的图形解决方案?

matlab - 在matlab中保存wav文件

C 编程和 vim

ide - WebStorm 和 PHPStorm 的区别

python - 如何调用列表中的字符串位置?

python - 如何在Python中从Elasticsearch访问索引值