在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
但是这会导致错误,我找不到如何从bytearray中获取b''字符串:
>>> print(base58.b58encode(my_ba))
TypeError: a bytes-like object is required, not 'bytearray'
我相信这显而易见,但我该如何将bytearray转换为带有b
前缀的字符串?
print(base58.b58encode(bytes(my_ba)))
- cs95zlib.decompress
方法中遇到了相同的字节参数限制。 - iruvar