【问题标题】:python.exe outputpython.exe 输出
【发布时间】:2011-04-13 11:01:34
【问题描述】:

我有一个使用 python 作为脚本语言的应用程序。当有人修改 python 脚本时,我想知道它是否有语法错误。我正在使用 python.exe(windows 2003,python 2.5)来检查脚本,所以我执行类似

python script.py > errors.txt

尽管script.py有语法错误,但是errors.txt仍然是0kb,在这种情况下,python检测到的错误会显示在屏幕上(但不会重定向到文件)

【问题讨论】:

  • python -ud script.py > errors.txt

标签: redirect syntax-error python


【解决方案1】:

如果 python 使用 STDERR 输出流来处理错误(我承认我不知道是不是这样),你必须使用以下方法重定向错误流:

python script.py 2> errors.txt

【讨论】:

  • 是的...那是...我正在写我自己的答案,但你先发布它。谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-05-19
  • 2017-08-02
  • 2021-12-17
  • 1970-01-01
  • 2020-06-07
  • 2012-03-31
  • 1970-01-01
相关资源
最近更新 更多