bytes()返回不可变字节数组类
bytearray()返回可变字节数组类
bytearray("何仝","unicode")
^
SyntaxError: invalid character in identifier
bytearray("何仝","utf-8")
File "<input>", line 1
bytearray("何仝","utf-8")
^
SyntaxError: invalid character in identifier
bytearray("何仝","utf-8")
bytearray(b'\xe4\xbd\x95\xe4\xbb\x9d')
bytearray("何仝","unicode")
Traceback (most recent call last):
File "<input>", line 1, in <module>
LookupError: unknown encoding: unicode
bytearray(b"何仝")
File "<input>", line 1
SyntaxError: bytes can only contain ASCII literal characters.
bytearray(b"he")
bytearray(b'he')
bytearray(u"he")
Traceback (most recent call last):
File "<input>", line 1, in <module>
TypeError: string argument without an encoding
bytearray()
bytearray(b'')
bytearray([1,2,3])
bytearray(b'\x01\x02\x03')
bytearray("何仝","utf-8")
bytearray(b'\xe4\xbd\x95\xe4\xbb\x9d')
bytearray(1)
bytearray(b'\x00')
bytearray(123)
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
bytearray(5)
bytearray(b'\x00\x00\x00\x00\x00')
bytes(3)
b'\x00\x00\x00'
type(bytes(3))
<class 'bytes'>
type(bytearray(3))
<class 'bytearray'>