(Python3)Bytes和Bytearray操作

特别说明:以下所有的指定范围只能从0-255以内

1、count

#计算子字符串(字符串表示的二进制数据)在规定范围内出现的次数
bytes.count(sub[, start[, end]])
bytearray.count(sub[, start[, end]])

2、decode

#返回指定编码的字符串表示二进制数据
bytes.decode(encoding="utf-8", errors="strict")
bytearray.decode(encoding="utf-8", errors="strict")

3、endswith

#判断给定的(字符串表示二进制数)是否在指定范围内的结尾(是否是指定范围内的后缀)
bytes.endswith(suffix[,start[,end]])
bytearray.endswith(suffix[,start[,end]])

4、find

#判断子指定范围的字符串(字符串表示二进制数据)是否存在字符串(字符串表示二进制数据)中
bytes.find(sub[,start[,end]]
bytearray.find(sub[,start[,end]]

5、index

#查找子字符串(字符串表示的二进制数据)在指定范围内的索引位置
bytes.index(sub[,start[,end]])
bytearray.index(sub[,start[,end]])

6、join

#以字节数组为分隔符,来显示迭代器中的内容
bytes.join(iterable)
batearray.join(iterable)

7、maketrans

#是一个静态方法
#将(to)指定的二进制数据字符,映射到表中相同位置,相同长度的(from)位置上
static bytes.maketrans(from, to)
static bytearray.maketrans(from, to)

  • 5
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值