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)

 

posted @ 2019-01-31 10:11  怒放吧!  阅读(157)  评论(0编辑  收藏  举报
我的