sys.stdout的 [英] sys.stdout

查看:71
本文介绍了sys.stdout的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




sys.stdout流在我的
Python2.4 shell中表现奇怪:

Hi,

The sys.stdout stream behaves strangely in my
Python2.4 shell:

import sys
sys.stdout.write(" AAAA")
sys.stdout.write(" BBBB \ n" ;)
BBBB sys.stdout.write(" CCCC \ nDDDD")
CCCC sys.stdout.flush()
import sys
sys.stdout.write("AAAA")
sys.stdout.write("BBBB\n") BBBB sys.stdout.write("CCCC\nDDDD") CCCC sys.stdout.flush()



[......什么都没有......]


你见过sys.stdout的表现如此吗?

我知道我的错误是什么Python2.4安装

或Linux(Mandrake 10.0)系统?


干杯,

$ b $bSébastien

推荐答案

SébastienBoisgéraultaécrit:
Sébastien Boisgérault a écrit :
sys.stdout流在我的Python2中表现奇怪。 4 shell:
The sys.stdout stream behaves strangely in my
Python2.4 shell:
>>> import sys
>>> sys.stdout.write(" AAAA")
>>> sys.stdout.write(" BBBB \ n")BBBB>>> sys.stdout.write(" CCCC \ nDDDD")CCCC>>> sys.stdout.flush()
>>> import sys
>>> sys.stdout.write("AAAA")
>>> sys.stdout.write("BBBB\n") BBBB >>> sys.stdout.write("CCCC\nDDDD") CCCC >>> sys.stdout.flush()


[...没有...]


[...nothing...]




有两件事在竞争你的标准输出:你明确地问了什么

编写的程序以及翻译的提示和回声。


试试这个:

导入系统,时间

sys.stdout.write(''aaa''); sys.stdout.flush(); time.sleep(2)



There are two things competing on your stdout: what you explicitely ask
the program to write and the prompt and echo of the interpreter.

Try this:

import sys, time
sys.stdout.write(''aaa''); sys.stdout.flush(); time.sleep(2)


Tiissa,


感谢您的回答。你的例子的执行导致在2秒内显示

''aaa'',然后被提示删除。


此行为是标准的?不应该标准输出

to * concatenate *'aaa''和''>>>''?


SB

Tiissa,

Thanks for your answer. The execution of your example leads to a
''aaa'' display during 2 secs, before it is erased by the prompt.

This behavior is standard ? The standard output is not supposed
to *concatenate* the ''aaa'' and the ''>>>'' ?

SB


S ?? bastien Boisg ?? rault写道:
S??bastien Boisg??rault wrote:
Tiissa,

感谢您的支持回答。在你的提示被删除之前,你的例子的执行会导致在2秒内显示
''aaa''。

这种行为是标准的吗?标准输出不应该*连接*'aaa''和''>>>''?
Tiissa,

Thanks for your answer. The execution of your example leads to a
''aaa'' display during 2 secs, before it is erased by the prompt.

This behavior is standard ? The standard output is not supposed
to *concatenate* the ''aaa'' and the ''>>>'' ?




FWIW :


Python 2.4.1(#2,2005年3月31日,00:05:10)

[GCC 3.3 20030304(Apple Computer,Inc。build) 1666)] on darwin

输入help,copyright,credit等等。或许可证或更多信息。



FWIW:

Python 2.4.1 (#2, Mar 31 2005, 00:05:10)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1666)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

import sys
sys.stdout.write(''AAAA'')
AAAA>>> sys.stdout.write(''BBBB \ n'')

BBBB
import sys
sys.stdout.write(''AAAA'') AAAA>>> sys.stdout.write(''BBBB\n'')
BBBB




-

Robert Kern
rk***@ucsd.edu

在地狱的地方,草地长得很高

梦想的坟墓是否能够死亡。

- Richard Harter



--
Robert Kern
rk***@ucsd.edu

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter


这篇关于sys.stdout的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆