【发布时间】:2013-12-17 14:04:32
【问题描述】:
我可以在python中打开一个shell窗口打印调试信息而不破坏代码的执行顺序吗?
例如:
def foo(b):
print b
for a in range(0, 100):
print a # normally this will be used for on-the-fly simple debugging purpose
# and will mess the console output of foo()
foo(a)
我可以这样做吗:
newshell = <new cmd.exe or bash>
for a in range(0, 100):
newshell.print(a) # information will be printed to new opened shell
foo(a)
提前致谢。
【问题讨论】:
-
让我明白这一点吗?你想把控制台打开吗?一个有实际输出,另一个有错误,对吗?您使用的是什么操作系统?
-
@Paulo Bu,我想要一个跨平台的解决方案,win32 是首选,因为 *nix 会更容易一些,因为它有 /dev/tty vty pty ...但 win32 没有这样的设备.
标签: python shell debugging redirect