Python Learning Python Basics week4-2

Source: Internet
Author: User

1, Bytes and ByteArray

# bytes: immutable byte sequence; ByteArray: byte array, variable data type;

(1) Bytes definition

class bytes (object):     """     (1) bytes (iterable_of_ints), Bytes    (2) bytes (string, encoding[, errors]), Bytes    (3) bytes ( Bytes_or_buffer)-Immutable copy of Bytes_or_buffer    (4) bytes (int), bytes object of size given by the Paramet Er initialized with null bytes # Specifies the byte of the bytes, which is filled by 0;
B=bytes # Create a 10-byte bytes;
Print (b) # ==> B ' \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 '; (5) bytes (), empty bytes Object # Create a null bytes;

# Note: The bytes type, defined using the B prefix;

Only allow ASCII-based use of string form B ' abc9 ' representation

Use 16 binary to represent B ' \x41\x61 '

(2) ByteArray definition

class ByteArray (object):     """     ByteArray (iterable_of_ints), ByteArray    ByteArray (String, encoding[, errors]), ByteArray    ByteArray (bytes_or_buffer), mutable copy of Bytes_or_buffer    bytearray (int), bytes array of size given by the parameter initialized with null bytes    ByteArray (), empty bytes array
# B=bytearray (5)
# print (b) # ByteArray (b ' \x00\x00\x00\x00\x00 ')
2. Character encoding

Python Learning Python Basics week4-2

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.