Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 将django manage.py输出(在windows中)重定向到文本文件_Python_Windows_Django_Command Line_Stdout - Fatal编程技术网

Python 将django manage.py输出(在windows中)重定向到文本文件

Python 将django manage.py输出(在windows中)重定向到文本文件,python,windows,django,command-line,stdout,Python,Windows,Django,Command Line,Stdout,我试图将manage.py的输出重定向到文本文件,但只有一些输出被重定向到文本文件。如何将所有输出重定向到文本文件 我的命令提示符: C:\Development\web-py\p1st2\pianos1st-system>python manage.py test > test_results.txt ...........................................................................................

我试图将manage.py的输出重定向到文本文件,但只有一些输出被重定向到文本文件。如何将所有输出重定向到文本文件

我的命令提示符:

C:\Development\web-py\p1st2\pianos1st-system>python manage.py test > test_results.txt
.....................................................................................................................
----------------------------------------------------------------------
Ran 117 tests in 2.026s

OK
我的测试结果.txt文件:

Creating test database for alias 'default'...
Destroying test database for alias 'default'...

我使用的是Windows 7 32位SP1和Django SVN。

某些类型的控制台消息将绕过输出重定向(或使用“>”调用的任何内容)。我注意到sys.stderr.write()就是这样做的

在末尾添加“2>&1”有助于:

python manage.py test purchaseplans > test_results.txt 2>&1
编辑:解释正在发生的事情:

这正是我想要的。谢谢