【发布时间】:2018-09-10 12:51:30
【问题描述】:
当我在 Linux 机器上运行 python3 解释器并尝试将它的 stdout 重定向到这样的文件时,没有任何反应:
user@workmachine:~$ python3 > python.txt
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
\>>>
文件python.txt 在解释器运行时以及关闭后保持为空。它的所有输出仍在终端中。
另一方面,如果我重定向 R 解释器
以同样的方式(R > R.txt)结果符合预期(所有输出重定向到文件,在终端中看不到任何内容)。
有什么区别? python 是否将其所有输出写入stdout 之外的另一个流,还是什么?
【问题讨论】:
-
@jww,你提到的问题是关于非交互模式的。请阅读我的回答的评论