接口:字节

方法

尺寸

size() 返回规则.Integer

返回字节序列中的字节数。

退货

non-null rules.Integer整数字节数。

例子

b'\xFF\xFF'.size() == 2
b'a'.size() == 1
b'€'.size() == 3 // 3-byte UTF-8 encoded string

转Base64

toBase64() 返回规则.String

返回与提供的字节序列对应的 Base64 编码字符串。

Base64 编码是根据base64url 规范执行的。

退货

non-null rules.String字符串 Base64 编码的字符串。

例子

b'\xFB\xEF\xBE'.toBase64() == '----'

转十六进制字符串

toHexString() 返回规则.String

返回与提供的字节序列对应的十六进制编码字符串。

退货

non-null rules.String十六进制编码的字符串。

例子

b'\x2A'.toHexString() == '2A'
b'**'.toHexString() == '2A2A'
b'€'.toHexString() == 'E282AC'