使用extend()方法追加bytearray
当使用append()方法向bytearray追加数据时,如果数据不是整数类型,将会报TypeError的错误。此时可以使用extend()方法来追加bytearray。例如:
arr1 = bytearray(b'hello') arr2 = bytearray(b' world') arr1.extend(arr2) print(arr1)
运行结果为:b'hello world'
上一篇:bytearray中包含空字符的PyByteArray_AsString的解决方案
下一篇:BYTEA为什么会被认为是TEXT格式?