Python 2.7中是否有等效的bash -x
如果您不熟悉bash,
$ ./hello.sh
Hello world
Hello world
Hello world
Hello world
Hello world
$ bash -x ./hello.sh
+ var=5
++ seq 1 5
+ for i in '`seq 1 $var`'
+ echo 'Hello world'
Hello world
+ for i in '`seq 1 $var`'
+ echo 'Hello world'
Hello world
+ for i in '`seq 1 $var`'
+ echo 'Hello world'
Hello world
+ for i in '`seq 1 $var`'
+ echo 'Hello world'
Hello world
+ for i in '`seq 1 $var`'
+ echo 'Hello world'
Hello world
这有助于快速调试流程等,即使对于运行时间很长的脚本也是如此。