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

Source: Internet
Author: User

Returns a new array object that cannot be modified by an array element. Range of values per element : 0 <= x <max. the main difference between the bytes function and the ByteArray function is that the elements of the object produced by the bytes function cannot be modified, and the elements of an object produced by the ByteArray function can be modified. Therefore, except for modifiable object functions that are not the same as the ByteArray function, all other usage methods are the same. Finally, its parameters are defined in the same way as 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 results are as follows:

B ' ABC '

B ' \x00 '

B ' \x02\x03\x06\x08 '


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

Related Article

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.