On Fri, Jun 16, 2017 at 7:06 PM, JAIDIP patel wrote:
> The code I wrote:
>
> import socket
>
> mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> mysock.connect(('data.pr4e.org', 80))
> mysock.send('GET http://data.pr4e.org/intro-short.txt HTTP/1.0\n\n')
> while True:
> data =x.recv(
Hi,
TypeError: a bytes-like object is required, not 'str'
...
mysock.send('GET http://data.pr4e.org/intro-short.txt HTTP/1.0\n\n')
Here you must encode the str as bytes:
mysock.send('GET http://data.pr4e.org/intro-short.txt
HTTP/1.0\n\n'.encode("UTF-8"))
The actual encoding does not
I just wrote the code with Python 3.6.1, I am just a beginner in python.
while compiling having below error, can anyone help me in this
TypeError: a bytes-like object is required, not 'str'
The code I wrote:
import socket
mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
mysock.connec