基本上我的问题是标题,
例如在shell中:
>>> import sys >>> sys.stdout.write('Hello') Hello5
(与stderr相同)
stderr
但是从一个文件:
import sys sys.stdout.write('Hello')
输出:
Hello
那为什么会这样呢???
那是回报值。 sys.stdout.write('Hello')返回5,它以交互模式自动打印,但不在脚本中打印。
sys.stdout.write('Hello')
5