[Tutor] byte array conversion question

Bill Allen wallenpb at gmail.com
Thu Feb 3 06:43:00 CET 2011


I have found that there are a couple of ways to convert a byte array to a
string in Python.   Is there any advantage or disadvantage to either method?

my_bytes = b'this is a test'

str(my_bytes,'utf-8')   yields 'this is a test'
my_bytes.decode('utf-8';)   yeilds 'this is a test'


--Bill
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110202/e9325d78/attachment.html>


More information about the Tutor mailing list