小编Cas*_*s22的帖子

Python3.3 HTML Client TypeError:'str'不支持缓冲区接口

import socket

# Set up a TCP/IP socket
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)

# Connect as client to a selected server
# on a specified port
s.connect(("www.wellho.net",80))

# Protocol exchange - sends and receives
s.send("GET /robots.txt HTTP/1.0\n\n")
while True:
        resp = s.recv(1024)
        if resp == "": break
        print(resp,)

# Close the connection when completed
s.close()
print("\ndone")
Run Code Online (Sandbox Code Playgroud)

错误:

cg0546wq@smaug:~/Desktop/440$ python3 HTTPclient.py
Traceback (most recent call last):
  File "HTTPclient.py", line 11, in <module>
    s.send("GET /robots.txt HTTP/1.0\n\n")
TypeError: 'str' does not support the buffer interface …
Run Code Online (Sandbox Code Playgroud)

html python string client

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

client ×1

html ×1

python ×1

string ×1