📜  Bytearray 类型 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:23.514000             🧑  作者: Mango

代码示例1
# Cast bytes to bytearray
mutable_bytes = bytearray(b'\x00\x0F')

# Bytearray allows modification
mutable_bytes[0] = 255
mutable_bytes.append(255)
print(mutable_bytes)

# Cast bytearray back to bytes
immutable_bytes = bytes(mutable_bytes)
print(immutable_bytes)