|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
查看help里面写的print
print(...)
print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)
Prints the values to a stream, or to sys.stdout by default.
Optional keyword arguments:
file: a file-like object (stream); defaults to the current sys.stdout.
sep: string inserted between values, default a space.
end: string appended after the last value, default a newline.
flush: whether to forcibly flush the stream.
其中有一个参数是flush,求问这个参数是干什么用的,并且是怎么用的
简单说就是将缓存里面的内容立即输出到标准输出流(这里是sys.stdout, 也就是默认的显示器)
这个功能在客户端脚本几乎用不上, 大多用于服务器端
比如反向Ajax里面就要用到flush, 举个例子: 在线web聊天页面会实时显示聊天的内容, 其实后台是一直在向服务器请求数据的, 正常情况下是请求完毕之后才会输出相应内容, 但是是即时聊天, 需要一有相应就得立即返回, flush也就起作用了 
|
|