Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sockets 属性错误:模块';插座';没有属性';AF#U蓝牙&x27;_Sockets_Bluetooth_Windows 10_Python 3.6 - Fatal编程技术网

Sockets 属性错误:模块';插座';没有属性';AF#U蓝牙&x27;

Sockets 属性错误:模块';插座';没有属性';AF#U蓝牙&x27;,sockets,bluetooth,windows-10,python-3.6,Sockets,Bluetooth,Windows 10,Python 3.6,我想在Python中使用蓝牙与我的机器人通信,所以我在网上寻找一些教程。我发现了一些使用我以前使用过的套接字模块的示例。所以我尝试使用它,但我得到了这个错误AttributeError:模块“socket”没有属性“AF\u BLUETOOTH”。我查看了官方的python文档,它就在那里。我正在使用Windows10和Python3.6.4 完整代码: import socket hostMACAddress = 'adress' port = 3 backlog = 1 size = 10

我想在Python中使用蓝牙与我的机器人通信,所以我在网上寻找一些教程。我发现了一些使用我以前使用过的套接字模块的示例。所以我尝试使用它,但我得到了这个错误
AttributeError:模块“socket”没有属性“AF\u BLUETOOTH”
。我查看了官方的python文档,它就在那里。我正在使用Windows10和Python3.6.4 完整代码:

import socket

hostMACAddress = 'adress'
port = 3
backlog = 1
size = 1024
s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM)
s.bind((hostMACAddress,port))
s.listen(backlog)
try:
    client, address = s.accept()
    while 1:
        data = client.recv(size)
        if data:
            print(data)
            client.send(data)
except:
    print("Closing socket")
    client.close()
    s.close()

欢迎来到SO。请分享你的完整代码!蓝牙插座在Windows上不可用。