为什么文本I / O必须在python 3中缓冲? [英] Why text I/O must be buffered in python 3?

查看:166
本文介绍了为什么文本I / O必须在python 3中缓冲?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Python 2支持无缓冲的文本I / O.

Python 2 supported unbuffered text I/O.

同样的方法在python 3中不起作用。为什么禁用了无缓冲的文本I / O?

The same approach doesn't work in python 3. Why was unbuffered text I/O disabled?

> import sys
> sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
builtins.ValueError: can't have unbuffered text I/O

二进制文件仍然正常工作:

The binary still works fine:

> sys.stdout = os.fdopen(sys.stdout.fileno(), 'wb', 0) # works fine


推荐答案

这是一个开放的bug,问题#17404(上次更新2013-03-13): http://bugs.python.org/issue17404

This is an open bug, issue # 17404 (last update 2013-03-13): http://bugs.python.org/issue17404

这篇关于为什么文本I / O必须在python 3中缓冲?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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