栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Python:-u选项的意义?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Python:-u选项的意义?

来自

python --help

-u     : unbuffered binary stdout and stderr; also PYTHonUNBUFFERED=x         see man page for details on internal buffering relating to '-u'

手册页指出:

-u     Force  stdin,  stdout and stderr to be totally unbuffered.  On

systems where it matters, also put stdin,
stdout and stderr in binary mode. Note that there is internal
buffering in xreadlines(), readlines()
and file-object iterators (“for line in sys.stdin”) which is
not influenced by this option. To work
around this, you will want to use “sys.stdin.readline()” inside a
“while 1:” loop.



Python以缓冲模式打开stdin,-out和-error流;它会读取或写入更大的块,将数据保留在内存中,直到达到阈值为止。

-u
禁用这些缓冲区。

此外,python可以解释打开文件上的换行符,并将它们与本机平台换行符进行相互转换(文本模式)。该

-u
选项禁用此转换,使您可以处理二进制数据,而不必担心
rn
组合可能会发生什么。使用此功能打开文件时,相当于使用
rb
wb
模式
open()



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/651130.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号