bytearray()返回一个新字节数组。
s = "Auffei"
s = s.encode()
print(s) #输出为b"luffei",b前缀代表的是字节。
s = bytearray(s) #返回一个新字节数组
print(s)
print(id(s)) #输出为 34697320
s[0] = 66
print(s)
print(id(s)) #输出地址同上,两个地址一样。s = "Auffei"
bytearray()返回一个新字节数组。
s = "Auffei"
s = s.encode()
print(s) #输出为b"luffei",b前缀代表的是字节。
s = bytearray(s) #返回一个新字节数组
print(s)
print(id(s)) #输出为 34697320
s[0] = 66
print(s)
print(id(s)) #输出地址同上,两个地址一样。s = "Auffei"