The optional
source
parameter can be used to initialize the array in a few different
ways:
If it is a
string
, you must also give the
encoding
(and optionally,
errors
) parameters; bytearray() then converts the string to bytes
using str.encode().
If it is an
integer
, the array will have that size and will be initialized
with null bytes.
If it is an object conforming to the
buffer
interface, a read-only
buffer of the object will be used to initialize the bytes array.
If it is an
iterable
, it must be an iterable of integers in the range 0
<= x < 256, which are used as the initial contents of the array.
Without an argument, an array of size 0 is created.
8、
callable(
object
)
Return True if the
object
argument appears callable, False if not. If this returns
true, it is still possible that a call fails, but if it is false, calling
object
will never
succeed. Note that classes are callable (calling a class returns a new instance);
class instances are callable if they have a __call__() method.
9、数字转化成字符
chr(
i
)