On Fri, Jan 26, 2018 at 3:43 AM, lewis <lewisn...@operamail.com> wrote:
> TypeError: a bytes-like object is required, not 'str' > > I found this at stackoverflow: In Python 3 (but not in Python 2), str and > bytes are distinct types that can't be mixed. You can't write a str > directly to a socket; you have to use bytes. > ​Good work, Lewis. Everything is hard at first for newbies, but you are doing what you can. In Leo, the best way (usually) to convert from a string to bytes type is with: b = g.toEncodedString(aString) This handles differences between python 2 and 3, and handles error checking when aString.encode throws an exception. It also works when aString is already a bytes object. Similarly, g.toUnicode(obj) is the best way to convert from bytes to unicode. You might like to look at these two very important functions. HTH. Edward -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To post to this group, send email to leo-editor@googlegroups.com. Visit this group at https://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/d/optout.