Python Socket Send Buffer Vs. Str

前端 未结 2 504
鱼传尺愫
鱼传尺愫 2020-12-03 12:31

I am trying to get a basic server (copied from Beginning Python) to send a str.

The error:

c.send( \"XXX\" )
TypeError: must be bytes or buffer, not          


        
2条回答
  •  甜味超标
    2020-12-03 12:52

    To add to Jacek Konieczny's answer: You can also use str.encode() to get bytes from a string. If you have the string in a variable instead of a literal, you can call encode and it will return an equivalent series of bytes.

提交回复
热议问题