bytes函数

# source是字符串,则使用str.encode()转换
b = bytes('abc',encoding='utf-8',errors='strict')

print(b,b[0])

# bytes对象不可变
try:
    b[0] = 100
except TypeError as err:
    print('it is immutable.so',err)
原文地址:https://www.cnblogs.com/ShuComputerProgram/p/10340739.html