如何保持Python脚本输出窗口打开?我刚开始学习Python。当我在Windows上执行python脚本文件时,输出窗口会出现,但会立即消失。我需要它呆在那里这样我就能分析我的输出了。我怎么才能把它打开呢?
3 回答
哈士奇WWW
TA贡献1799条经验 获得超6个赞
cmd /k
cmd /k
莫回无
TA贡献1865条经验 获得超7个赞
Python 2
if __name__ == '__main__': try: ## your code, typically one function call except Exception: import sys print sys.exc_info()[0] import traceback print traceback.format_exc() print "Press Enter to continue ..." raw_input()
if __name__ == '__main__': try: ## your code, typically one function call except Exception: import sys print sys.exc_info()[0] import traceback print traceback.format_exc() finally: print "Press Enter to continue ..." raw_input()
Python 3
input()
raw_input()
print
if __name__ == '__main__': try: ## your code, typically one function call except BaseException: import sys print(sys.exc_info()[0]) import traceback print(traceback.format_exc()) print("Press Enter to continue ...") input()
if __name__ == '__main__': try: ## your code, typically one function callexcept BaseException: import sys print(sys.exc_info()[0]) import traceback print(traceback.format_exc())finally: print("Press Enter to continue ...") input()
添加回答
举报
0/150
提交
取消