-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFunctions_bytes().py
29 lines (19 loc) · 1.06 KB
/
Functions_bytes().py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Python bytes() Function
# Example
# Return an array of 4 bytes:
x = bytes(4)
# Definition and Usage
# The bytes() function returns a bytes object.
# It can convert objects into bytes objects, or create empty bytes object of the specified size.
# The difference between bytes() and bytearray() is that bytes() returns an object that cannot be modified, and bytearray() returns an object that can be modified.
# Syntax
# bytes(x, encoding, error)
# Parameter Values
# Parameter Description
# x A source to use when creating the bytes object.
# If it is an integer, an empty bytes object of the specified size will be created.
# If it is a String, make sure you specify the encoding of the source.
# encoding The encoding of the string
# error Specifies what to do if the encoding fails.
# Related Pages
# The bytearray() Function