import socket
target_host = "cn.bing.com"
target_port = 80
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect((target_host,target_port))
client.send("GET / HTTP/1.1\r\nHost:cn.bing.com\r\n\r\n")
response = client.recv(4096)
print(response)
TypeError: a bytes-like object is required, not 'str'
python 初学者,错误提示是需要把 str encode 到字节流:
但是还是不知道怎么做才好。。
烦请 v 友指点下,谢谢!