Python standard library: built-in function bytes ([source [, encoding [, errors]), pythonencoding

Source: Internet
Author: User

Python standard library: built-in function bytes ([source [, encoding [, errors]), pythonencoding

Returns a new array object. The array object cannot be modified. Value range of each element: 0 <= x <256. The main difference between the bytes function and the bytearray function is that the elements of the objects generated by the bytes function cannot be modified, while the elements of the objects generated by the bytearray function can be modified. Therefore, except for modifiable object functions and bytearray functions, all other usage methods are the same. Finally, Its Parameter definition method is the same as that of the bytearray function.

Example:

# Bytes () function a = bytes ('abc', 'utf-8') print (a) B = bytes (1) print (B) c = bytes ([2, 3, 6, 8]) print (c)

The output result is as follows:

B 'abc'

B '\ x00'

B '\ x02 \ x03 \ x06 \ x08'



In pthon, bytearray ([source [, encoding [, errors]) explains what are the three variables behind it?

It is written in the document. Let's take a look at several situations.

How to view built-in functions in python

Import sys
Print dir (sys. modules ['_ builtin _'])

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.