Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.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
Python 蓝牙服务器接收到错误的文本数据RFCOMM_Python_String_Bluetooth_Server_Rfcomm - Fatal编程技术网

Python 蓝牙服务器接收到错误的文本数据RFCOMM

Python 蓝牙服务器接收到错误的文本数据RFCOMM,python,string,bluetooth,server,rfcomm,Python,String,Bluetooth,Server,Rfcomm,我在Python3上创建了简单的蓝牙RFCOMM服务器 这是我的密码: import bluetooth class Bluetooth: def __init__(self, port, backlog, size): #backlog = number of users who can connect to socket at the same time #size = message size s = bluetooth.Blue

我在Python3上创建了简单的蓝牙RFCOMM服务器

这是我的密码:

import bluetooth

class Bluetooth:
    def __init__(self, port, backlog, size):
        #backlog =  number of users who can connect to socket at the same time
        #size = message size
        s = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
        s.bind(("", port))  #(mac addres, port)
        s.listen(backlog)
        print("Server is active, waiting for connection!")

        while True:
            client, clientInfo = s.accept()
            print("Connected with :", clientInfo)
            try:
                while True:
                    data = client.recv(size)
                    if data:
                        print(data)
            except:
                print("Closing socket")
                client.close()
            print("Waiting for connection!")

        s.close()
        print("Server closed!")
当我从android设备应用程序(如BlueTerm、BlueTerm2、Bluetooth Terminal(…)发送数据时,我从PyCharm获得
b'my string'
屏幕截图

我的文本数据前面的
b
符号是什么意思?
如何仅打印字符串?

这是否回答了您的问题?