Python 中什么时候出现了 bytes() 函数?
Python 中从哪个版本开始存在 bytes() 函数?我正在编写一些必须与尽可能多的 python 版本兼容的代码,因此此类信息对我来说非常重要。有没有一个好的来源可以轻松找到此类问题的答案?
Since which version does the bytes() function exist in Python? I'm writing some code that has to be compatible with as much versions of python as possible, so this kind of information is very important to me. Is there a good source to find the answer to such questions easily?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
另外,还有一些文档可供阅读:
http://www.python.org/dev/peps/pep-0358/
Also, there's documentation to read up on:
http://www.python.org/dev/peps/pep-0358/
PEP 3112 添加了对 Python3 中字节文字的支持。 Python 3 采用 Unicode 作为语言的基本字符串类型,并将 8 位文字表示为
b'string'
或使用bytes
构造函数。为了以后的兼容性,Python2.6中引入了bytes。但请注意,2.6 字节与 3.x 字节不同,其用途也不同。
2.6 文档有哪些新增内容。
PEP 3112 added support for bytes literal in Python3. Python 3 adopted Unicode as the language’s fundamental string type and denoted 8-bit literals either as
b'string'
or using abytes
constructor.For future compatiblity, bytes was introduced in Python2.6. But note that in 2.6 bytes is different and serves a different purpose than 3.x bytes.
The most accurate and a concise explaination of inclusion of bytes in Python2.6 is given in what's new 2.6 document.