bytes() or .encode() for encoding str's as bytes?

Malcolm Greene python at bdurham.com
Fri Aug 31 11:27:55 EDT 2018


Is there a benefit to using one of these techniques over the other?
Is one approach more Pythonic and preferred over the other for
style reasons?
message = message.encode('UTF-8')
message = bytes(message, 'UTF-8')

Thank you,
Malcolm



More information about the Python-list mailing list