Since when does the bytes() function exist in Python?
Since which version does the b开发者_运维百科ytes() 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?
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 a bytes
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.
Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> bytes()
''
Also, there's documentation to read up on: http://www.python.org/dev/peps/pep-0358/
精彩评论