This is my code z = (priv.to_string().encode('hex'))
and I got this error:
"AttributeError: 'bytes' object has no attribute 'encode'"
looks like I missed something to show "encode" after the code:
z = (priv.to_string().
Two problems here:
priv.to_string() (which isn't a built-in method) instead of str(priv)'hex' has been removed as an encoding in Python 3, so with str(priv).encode('hex') you'll get the following error: LookupError: 'hex' is not a text encoding; use codecs.encode()to handle arbitrary codecsHowever, since Python 3.5, you can simply do:
priv.hex()
with priv being a byte string.
Example:
priv = b'test'
print(priv.hex())
Output:
74657374
priv's type? Trystr(priv)rather thanpriv.to_string()