Python 蓝牙服务器接收到错误的文本数据RFCOMM
我在Python3上创建了简单的蓝牙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
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
符号是什么意思?
如何仅打印字符串?这是否回答了您的问题?