On Fri, Jul 22, 2016 at 6:52 PM, Yubin Ruan <ablacktsh...@gmail.com> wrote: > In my understanding, writing to a file would requires that everything be > written byte by byte. So writing objects of type 'bytes' to socket makes > sense. But, how could python write to file using unicode(type 'str')? Does > python encode 'str'(Unicode) automatically before writing things to file? If > it's true, then why can't it do that automatic encoding when I trying to > write a 'str' to socket ? >
Did you specify an encoding when you opened the file? Did you specify an encoding when you opened the socket? ChrisA -- https://mail.python.org/mailman/listinfo/python-list