命令 python -i script.py
将运行给定的脚本,然后将我放入一个交互式 repl,其中可以访问脚本中的函数和变量。有 Perl 类似物吗?
编辑:如果有帮助,这里是 python -i
的另一个描述 https://docs.python.org/3.4/using/cmdline.html#cmdoption-i
When a script is passed as first argument or the -c option is used, enter interactive mode after executing the script or the command, even when sys.stdin does not appear to be a terminal. The PYTHONSTARTUP file is not read.
This can be useful to inspect global variables or a stack trace when a script raises an exception
请您参考如下方法:
perl -d script.pl
然后点击 c<ENTER>
可能足够接近,
c [ln|sub] Continue until position
perl -MData::Dumper -de '%h = 1..4'
Loading DB routines from perl5db.pl version 1.44
Editor support available.
Enter h or 'h h' for help, or 'man perldebug' for more help.
main::(-e:1): %h = 1..4
DB<1> print Dumper \%h
$VAR1 = {};
DB<2> c
Debugged program terminated. Use q to quit or R to restart,
use o inhibit_exit to avoid stopping after program termination,
h q, h R or h o to get additional info.
DB<2> print Dumper \%h
$VAR1 = {
'3' => 4,
'1' => 2
};