AttributeError:“\u socketobject”对象没有属性“bind”

2024-04-27 02:45:13 发布

您现在位置:Python中文网/ 问答频道 /正文

这是我的代码:

import sae
import socket, sys
host = ''
port = 5005
def app(environ, start_response):
    status = '200 OK'
    response_headers = [('Content-type', 'text/plain')]
    start_response(status, response_headers)
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.bind((host, port))
    s.listen(2)
    while 1:
        client, addr = s.accept();
        print("Got connection from ", addr);
        while 1:
            print("the word you want to send:")
            buf = sys.stdin.readline().strip()
            if not buf:
                break
            client.send(bytes(buf, 'UTF-8'))
            data = client.recv(1024);
            if data:
                print(data)
    return ['Hello, world!']

application = sae.create_wsgi_app(app)

但是我得到一个属性错误,它说:

^{pr2}$

我真的不明白我需要做些什么来解决这个问题。如果有人能帮助我,我将非常感激。在


Tags: importclientapphostdataportresponsestatus