字符串 字节
a. 字符串转字节
key = "xxxx" bkey = bytes(key,encoding='utf-8')
b. bytearray 数组
data = "要加密" ba_data = bytearray(data,encoding="utf-8") print(ba_data) # bytearray(b'\xe8\xa6\x81\xe5\x8a\xa0\xe5\xaf\x86') print(len(ba_data)) # 9 ba_data.append(11) #只能追加数字,默认转成字节