在Python 3中,我得到了错误TypeError: a bytes-like object is required, not 'bytearray'
我有一个字节数组,看起来像这样:
>>> print(my_ba)
bytearray(b'}\x0e\x15/ow4|-')
如果我在控制台中输入它,它会工作:
>>> print(base58.b58encode(b'}\x0e\x15/ow4|-'))
2bKmhuGiGP7t8
但这给出了一个错误,我无法找到如何从字节数组中获取b''字符串:
>>> print(base58.b58encode(my_ba))
TypeError: a bytes-like object is required, not 'bytearray'
我相信这是显而易见的,但我如何将字节数组转换为前缀为b的字符串呢?